PAT(甲级)1035. Password (20)

来源:互联网 发布:百万公众网络测试登录 编辑:程序博客网 时间:2024/06/10 19:00

题目:https://www.patest.cn/contests/pat-a-practise/1035

代码:

#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>using namespace std;struct stu{     char id[15]; char pas[15]; int flag;}a[1005];int main(){int n,i,count=0,j;scanf("%d",&n);for(i=0;i<n;i++){scanf("%s %s",&a[i].id,&a[i].pas);int length=strlen(a[i].pas);for(j=0;j<length;j++){if(a[i].pas[j]=='0'||a[i].pas[j]=='O'||a[i].pas[j]=='l'||a[i].pas[j]=='1'){a[i].flag=1;if(a[i].pas[j]=='0'){    a[i].pas[j]='%';}else if(a[i].pas[j]=='O'){    a[i].pas[j]='o';}else if(a[i].pas[j]=='1'){    a[i].pas[j]='@';}else if(a[i].pas[j]=='l'){    a[i].pas[j]='L';}}}}for(i=0;i<n;i++){if(a[i].flag==1){count++;}}if(count==0&&n>1){printf("There are %d accounts and no account is modified",n);}else if(count==0&&n==1){printf("There is %d account and no account is modified",n);}else{   printf("%d\n",count);   for(i=0;i<n;i++){   if(a[i].flag==1){   printf("%s %s\n",a[i].id,a[i].pas);   }    }}   system("pause");} 

0 0
原创粉丝点击