字符串模拟题:
注意提议就好了
#include <iostream>
using namespace std;
#include <vector>
int main() {
int m;
cin >> m;
string id, pwd;
vector<string> p, I;
int cnt = 0;
while(m--) {
bool flag = false;
//记录次数,后面为了方便表达
cin >> id >> pwd;
cnt++;
for(int i = 0; i < pwd.size(); i++) {
if(pwd[i] == '1' || pwd[i] == '0' || pwd[i] == 'l' || pwd[i] == 'O') {
if(pwd[i] == '1') pwd[i] = '@';
if(pwd[i] == '0')pwd[i] = '%';
if(pwd[i] == 'l') pwd[i] = 'L';
if(pwd[i] == 'O') pwd[i] = 'o';
flag = true;
}
}
if(flag) {
I.push_back(id);
p.push_back(pwd);
}
}
if(!p.size()) {
cout << "There"<<(cnt==1?" is ":" are ") << cnt <<(cnt==1?" account":" accounts")<<" and no account is modified";
}
else {
cout <<p.size()<<endl;
for(int i = 0; i < p.size(); i++) {
cout<<I[i]<<" "<<p[i]<<endl;
}
}
return 0;
}