1035 Password
作者:互联网
题意:给定n个用户信息,修改不符合规范的密码,输出修改记录。
#include<iostream>
using namespace std;
struct ss {
string name,psw;
};
int main() {
int n;
cin>>n;
struct ss s[n];
int count=0;//修改个数
int ans[n];//修改记录
for(int i=0; i<n; ++i) {
int flag=0;
cin>>s[i].name>>s[i].psw;
for(int j=0; j<s[i].psw.size(); ++j)
if(s[i].psw[j]=='1') {
flag=1;
s[i].psw[j]='@';
} else if(s[i].psw[j]=='0') {
flag=1;
s[i].psw[j]='%';
} else if(s[i].psw[j]=='l') {
flag=1;
s[i].psw[j]='L';
} else if(s[i].psw[j]=='O') {
flag=1;
s[i].psw[j]='o';
}
if(flag)
ans[count++]=i;
}
if(!count) {
if(n==1)
cout<< "There is 1 account and no account is modified\n";
else cout<<"There are "<<n<<" accounts and no account is modified\n";
} else {
cout<<count<<endl;
for(int i=0; i<count; ++i)
cout<<s[ans[i]].name<<" "<<s[ans[i]].psw<<endl;
}
return 0;
}
江楚郎(已婚 发布了237 篇原创文章 · 获赞 14 · 访问量 1万+ 私信 关注
标签:struct,int,name,修改,Password,ss,psw,1035 来源: https://blog.csdn.net/qq_40991687/article/details/104075025