注意点:n == 1和n > 1时,如果没有密码被改变,输出的格式是不一样的。
n == 1:
There is 1 account and no account is modified
n > 1:
There are 2 accounts and no account is modified
#include <iostream>
#include <vector>
using namespace std;
struct User{
string username;
string password;
};
vector<User> users;
int main(){
int n;
scanf("%d",&n);
for(int i = 0;i < n;i++){
string name,pwd;
name.resize(100);
pwd.resize(100);
scanf("%s %s",&name[0],&pwd[0]);
bool modified = false;
for(int j = 0;j < pwd.size();j++){
switch(pwd[j]){
case '1':
pwd[j] = '@';
modified = true;
break;
case 'l':
pwd[j] = 'L';
modified = true;
break;
case '0':
pwd[j] = '%';
modified = true;
break;
case 'O':
pwd[j] = 'o';
modified = true;
break;
}
}
if(modified == true){
User temp = {name,pwd};
users.push_back(temp);
}
}
if(users.size() != 0){
printf("%d\n",users.size());
for(unsigned int i = 0;i < users.size();i++){
printf("%s %s\n",users[i].username.c_str(),users[i].password.c_str());
}
}
else{
if(n > 1){
printf("There are %d accounts and no account is modified",n);
}
else
printf("There is %d account and no account is modified",n);
}
system("pause");
return 0;
}