本题为字符串替换
#include<iostream>
#include<string>
using namespace std;
int check(string& str) {
for (int i = 0; i < str.length(); i++) {
if (str.find("0")==-1 && str.find("O") == -1 && str.find("1") == -1 && str.find("l") == -1) {
return 0;
}
else {
return 1;
}
}
}
string cha(string& str) {
for (int i = 0; i < str.length(); i++) {
if (str[i] == '1')
str[i] = '@';
else if(str[i] == 'l')
str[i] = 'L';
else if (str[i] == '0')
str[i] = '%';
else if (str[i] == 'O')
str[i] = 'o';
}
return str;
}
int main() {
int n,N=0,M=0;
string na[1001];
string ps[1001];
cin >> n;
for (int i = 0; i < n; i++) {
string name, pass;
cin >> name>>pass;
if (check(pass) == 0)
N++;
else {
na[M] = name;
ps[M] = cha(pass);
M++;
}
}
if (n == N) {
if (n == 1)
cout << "There is 1 account and no account is modified";
else
cout << "There are " << n << " accounts and no account is modified";
}
else {
cout << M << endl;
for (int j = 0; j <M; j++) {
cout << na[j] << ' ' << ps[j] <<endl;
}
}
}