题目链接:1035 Password
#include <iostream>
#include <vector>
using namespace std;
struct user{
string name, passwords;
};
int main(){
int n;
cin >> n;
vector<user> ans;
for(int i = 0; i < n; i++){
string name, password;
cin >> name >> password;
int flag = 0, temp;//flag标记本次输入是否有字符替换发生
for(int j = 0; j < password.length(); j++){
if(!flag) temp = password[j];//记录password当前字符
if(password[j] == '1') password[j] = '@';
else if(password[j] == '0') password[j] = '%';
else if(password[j] == 'l') password[j] = 'L';
else if(password[j] == 'O') password[j] = 'o';
if(!flag && temp != password[j]) flag = 1;//比对是否中途有修改
}
if(flag) ans.push_back({name, password});
}
if(ans.size() == 0){//未发生替换,分两种情况
if(n != 1)printf("There are %d accounts and no account is modified", n);
else printf("There is 1 account and no account is modified");
return 0;
}
printf("%lu\n", ans.size());
for(auto user: ans){//发生替换,顺序输出ans中的内容
printf("%s %s\n", user.name.c_str(), user.passwords.c_str());
}
}
博客给出了题目链接 1035 Password,但未提供更多关键信息。

1387

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



