1035 Password (20 point(s))
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.
题意
有一些很难区分,1 和L 0和O等。
replace 1
(one) by @
, 0
(zero) by %
, l
by L
, and O
by o
.
没别的。注意结果输出的时候 is 和are 还有单复数
if(CNT==1)
cout<<"There is "<<CNT<<" account and no account is modified"<<endl;
else
cout<<"There are "<<CNT<<" accounts and no account is modified"<<endl;
#include <iostream>
#include <string>
#include <vector>
using namespace std;
struct Node{
string name;
string pwd;
};
int CNT;
vector<Node> res;
bool replace(string &s){
bool ret =false;
for(int i=0;i<s.size();i++){
if(s[i]=='1'){s[i]='@';ret =true;}
else if(s[i]=='0'){s[i]='%';ret =true;}
else if(s[i]=='l'){s[i]='L';ret =true;}
else if(s[i]=='O'){s[i]='o';ret =true;}
}
return ret;
}
int main(){
cin>>CNT;
string temp_name,temp_pwd;
for(int i=0;i<CNT;i++){
cin>>temp_name>>temp_pwd;
if(replace(temp_pwd)){
res.push_back(Node{temp_name,temp_pwd});
}
}
if(res.size()){
cout<<res.size()<<endl;
for(int i=0;i<res.size();i++){
cout<<res[i].name<<" "<<res[i].pwd<<endl;
}
}
else{
if(CNT==1)
cout<<"There is "<<CNT<<" account and no account is modified"<<endl;
else{
cout<<"There are "<<CNT<<" accounts and no account is modified"<<endl;
}
}
return 0;
}