首页 > 其他 > 详细

【PAT甲级】1035 Password (20 分)

时间:2019-09-18 22:15:59      阅读:87      评论:0      收藏:0      [点我收藏+]

题意:

输入一个正整数N(<=1000),接着输入N行数据,每行包括一个ID和一个密码,长度不超过10的字符串,如果有歧义字符就将其修改。输出修改过多少组密码并按输入顺序输出ID和修改后的密码,如果没有修改过就输出There are N accounts and no account is modified。(根据样例如果N==1,are改成is并且accounts不加s)

代码:

#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
char s[1007][17];
char x[1007][17];
int ans[1007];
int main(){
int n;
cin>>n;
int cnt=0;
for(int i=1;i<=n;++i){
cin>>x[i];
cin>>s[i];
int flag=0;
for(int j=0;s[i][j]!=0;++j){
if(s[i][j]==‘1‘)
s[i][j]=‘@‘,flag=1;
else if(s[i][j]==‘0‘)
s[i][j]=‘%‘,flag=1;
else if(s[i][j]==‘l‘)
s[i][j]=‘L‘,flag=1;
else if(s[i][j]==‘O‘)
s[i][j]=‘o‘,flag=1;
}
if(flag)
ans[++cnt]=i;
}
if(!cnt&&n==1)
cout<<"There is "<<n<<" account and no account is modified";
else if(!cnt&&n>1)
cout<<"There are "<<n<<" accounts and no account is modified";
else{
cout<<cnt<<"\n";
for(int i=1;i<=cnt;++i)
cout<<x[ans[i]]<<" "<<s[ans[i]]<<"\n";
}
return 0;
}

【PAT甲级】1035 Password (20 分)

原文:https://www.cnblogs.com/ldudxy/p/11545381.html

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!