http://pat.zju.edu.cn/contests/pat-a-practise/1035
创建结构体存信息方便。
//
#include <stdio.h>
#include <string.h>
#define SIZE 15
#define MAXSIZE 1000+5
void replace(char a[], char b[])
{
int i=0;
while(a[i] != 0)
{
switch(a[i])
{
case '1': b[i]='@'; break;
case '0': b[i]='%'; break;
case 'l': b[i]='L'; break;
case 'O': b[i]='o'; break;
default:
b[i] = a[i];
break;
}
i++;
}
}
int main()
{
#ifdef ONLINE_JUDGE
#else
freopen("E:\\in.txt", "r", stdin);
freopen("E:\\out.txt", "w", stdout);
#endif
int n;
scanf("%d", &n);
if(n == 1)
{
puts("There is 1 account and no account is modified");
return 0;
}
int m=0;
char name[SIZE], pre[SIZE], after[SIZE];
char buf[MAXSIZE][SIZE*2];
memset(buf, 0, sizeof(buf));
int num = n;
while(num-->0)
{
memset(name, 0, sizeof(name));
memset(pre, 0, sizeof(pre));
memset(after, 0, sizeof(after));
scanf("%s %s", name, pre);
replace(pre, after);
if(strcmp(pre, after) != 0)
{
strcpy(buf[m], name);
strcat(buf[m], " ");
strcat(buf[m], after);
//strcat(buf[m], "\0");
m++;
}
}
if(m > 0)
{
printf("%d\n", m);
int i;
for(i=0; i<m; i++)
{
printf("%s\n", buf[i]);
}
}
else
{
printf("There are %d accounts and no account is modified\n", n);
}
return 0;
}