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.
/* 可爱的简单题目 QvQ..
* 午睡操场传来蝉的声音 多少年后也还是很好听~~
*/
#include "iostream"
#include "cstring"
#include "string"
#include "stack"
using namespace std;
struct Node {
char account[11];
char pwd[11];
bool flag = 0;
};
const char s1[4] = { '1','0','l','O' };
const char s2[4] = { '@','%','L','o' };
int main() {
Node node[1001];
int n;
int cnt = 0;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> node[i].account >> node[i].pwd;
for (int j = 0; node[i].pwd[j]; j++) {
for (int k = 0; k < 4; k++) {
if (node[i].pwd[j] == s1[k]) {
node[i].pwd[j] = s2[k];
node[i].flag = 1;
}
}
}
if (node[i].flag)
cnt++;
}
if (n == 1 && cnt==0)
cout << "There is 1 account and no account is modified" << endl;
else if(cnt == 0){
cout << "There are "<< n << " accounts and no account is modified" << endl;
}
else {
cout << cnt << endl;
for (int i = 0; i < n; i++) {
if (node[i].flag)
cout << node[i].account << " " << node[i].pwd << endl;
}
}
return 0;
}
本文介绍了一个简单的程序设计问题,即如何通过替换特定字符来避免密码混淆。程序接收一系列用户名及对应的密码作为输入,并将易混淆的字符(如1、0、l、O)替换为指定字符(@、%、L、o),以提高密码的可读性和安全性。
1991

被折叠的 条评论
为什么被折叠?



