PAT:1035. Password (20) AC
#include<stdio.h>
#include<string.h>
typedef struct STU
{
char mID[15];
char mpass[15];
bool tag;
}STU;
STU arr[1010];
int main()
{
memset(arr,0,sizeof(arr));
int n,change=0;
scanf("%d",&n);
for(int i=0 ; i<n ; ++i)
{
scanf("%s %s",&arr[i].mID,&arr[i].mpass);
int len=strlen(arr[i].mpass);
int tag=0; //判断这个输入是否改过
for(int j=0 ; j<len ; ++j)
{
if(arr[i].mpass[j]=='1'){
++tag;
arr[i].tag=1;
arr[i].mpass[j]='@';
}
else if(arr[i].mpass[j]=='0'){
++tag;
arr[i].tag=1;
arr[i].mpass[j]='%';
}
else if(arr[i].mpass[j]=='O'){
++tag;
arr[i].tag=1;
arr[i].mpass[j]='o';
}
else if(arr[i].mpass[j]=='l'){
++tag;
arr[i].tag=1;
arr[i].mpass[j]='L';
}
}
if(tag!=0)
++change; //记录改变数的个数
}
if(n==1 && change==0)
printf("There is 1 account and no account is modified");
else if(n>1 && change==0)
printf("There are %d accounts and no account is modified",n);
else
{
printf("%d\n",change);
for(int i=0 ; i<n ; ++i)
{
if(arr[i].tag==1)
printf("%s %s\n",arr[i].mID,arr[i].mpass);
}
}
return 0;
}