1035. Password (20)

简介: To prepare for PAT, the judge sometimes has to generate random passwords for the users.

To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) from O (o in uppercase). One solution is to replace 1 (one) by @, 0 (zero) by %, l by L, and O by o. Now it is your job to write a program to check the accounts generated by the judge, and to help the juge modify the confusing passwords.

Input Specification:

Each input file contains one test case. Each case contains a positive integer N (<= 1000), followed by N lines of accounts. Each account consists of a user name and a password, both are strings of no more than 10 characters with no space.

Output Specification:

For each test case, first print the number M of accounts that have been modified, then print in the following M lines the modified accounts info, that is, the user names and the corresponding modified passwords. The accounts must be printed in the same order as they are read in. If no account is modified, print in one line "There are N accounts and no account is modified" where N is the total number of accounts. However, if N is one, you must print "There is 1 account and no account is modified" instead.

Sample Input 1:

3
Team000002 Rlsp0dfa
Team000003 perfectpwd
Team000001 R1spOdfa
Sample Output 1:
2
Team000002 RLsp%dfa
Team000001 R@spodfa
Sample Input 2:
1
team110 abcdefg332
Sample Output 2:
There is 1 account and no account is modified
Sample Input 3:
2
team110 abcdefg222
team220 abcdefg333
Sample Output 3:
There are 2 accounts and no account is modified
思路:结构体存储 index记录已更改密码的下标。 一次ac 没有难度(set 4太难了 来刷pat 20分题冷静一下) 
#include <iostream>
using namespace std;

int main(int argc, const char * argv[]) {
    struct node{
        string name;
        string password;
    } s[1000];
    int index[1000] = {0}, m = 0, n;
    
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        cin >> s[i].name >> s[i].password;
        int flag = 0;
        for (int j = 0; j < s[i].password.length(); j++) {
            if (s[i].password[j] == '1') { s[i].password[j] = '@'; flag = 1;}
            else if (s[i].password[j] == '0') { s[i].password[j] = '%'; flag = 1;}
            else if (s[i].password[j] == 'l') { s[i].password[j] = 'L'; flag = 1;}
            else if (s[i].password[j] == 'O') { s[i].password[j] = 'o'; flag = 1;}
        }
        if (flag) { index[m++] = i; }
    }
    if (m > 0) {
        cout << m << endl;
        for (int i = 0; i < m; i++) {
            cout << s[index[i]].name << ' ' << s[index[i]].password << endl;
        }
    }else{
        if (n == 1) {
            printf("There is %d account and no account is modified\n", n);
        }else{
            printf("There are %d accounts and no account is modified\n", n);
        }
    }
    
    return 0;
}

目录
相关文章
|
数据安全/隐私保护
Shiro之UsernamePasswordToken&RememberMeAuthenticationToken&AuthenticationToken
Shiro之UsernamePasswordToken&RememberMeAuthenticationToken&AuthenticationToken
|
开发工具 git
Incorrect username or password (access token)
Incorrect username or password (access token)
191 0
Incorrect username or password (access token)
|
程序员 数据安全/隐私保护
问题 E: Double Password
ICPC总部的一台电脑有一个四位数字的密码保护——为了登录,你通常需要准确地猜出这四位数字。然而,实现密码检查的程序员在计算机上留下了一个后门——有第二个四位数字的密码。如果程序员输入一个四位数的密码序列,并且输入的每一个数字的位置至少与两个相同位置的密码中的一个匹配,那么这个四位数的密码序列将使程序员登录计算机。给定这两个密码,计算可以输入登录计算机的不同四位数字序列的数量。
159 0
|
NoSQL Redis 数据安全/隐私保护
AUTH password
为redis服务请求设置一个密码。redis可以设置在客户端执行commands请求前需要通过密码验证。通过修改配置文件的requirepass就可以设置密码。 如果密码与配置文件里面设置的密码一致,服务端就会发会一个OK的状态码,接受客户端发送其他的请求命令,否则服务端会返回一个错误码,客户端需要尝试使用新的密码来进行连接。
1132 0
|
数据安全/隐私保护 网络架构 网络安全
|
数据安全/隐私保护 网络架构 网络安全
|
数据安全/隐私保护