AcWing 1519. 密码
原题链接
简单
作者:
xxxxuu
,
2021-04-16 17:32:15
,
所有人可见
,
阅读 3
#include <iostream>
using namespace std;
const int N=1010;
string name[N],code[N];
int main(){
int n;
int count=0;//修改密码的个数,初值为0
cin>>n;
for(int i=0;i<n;i++){
string id,password;
cin>>id>>password;
string s=password;//用来暂存原来的密码,用于最后的判断输出
int len=password.length();
for(int j=0;j<len;j++){//根据题目条件判断是否需要修改密码
if(password[j]=='1'){
password[j]='@';
}
if(password[j]=='0'){
password[j]='%';
}
if(password[j]=='l'){
password[j]='L';
}
if(password[j]=='O'){
password[j]='o';
}
}
if(s!=password){//当前密码被修改过,更新count值并将账户和密码存入数组
name[count]=id;
code[count]=password;
count++;
}
}
if(count==0){//没有要修改的密码
if(n==1){
printf("There is 1 account and no account is modified");
}
else{
printf("There are %d accounts and no account is modified",n);
}
}
else{
cout<<count<<endl;
for(int i=0;i<count;i++){
cout<<name[i]<<" "<<code[i]<<endl;
}
}
return 0;
}