PAT 1035 password 翻译 分析 代码

#include<string.h>
#include<stdio.h>
struct p{
	char id[15],password[15];
	bool judge;
}team[1005];

void jud(p &a,int &count){
	for(int i=0;i<strlen(a.password);i++)
{
	if(a.password[i]=='1')
	{
		a.password[i]='@';
		a.judge=true;
	}
	if(a.password[i]=='0')
	{
		a.password[i]='%';
		a.judge=true;
	}
	if(a.password[i]=='l')
	{
		a.password[i]='L';
		a.judge=true;
	}
	if(a.password[i]=='O')
	{
		a.password[i]='o';
		a.judge=true;
	}
}
		if(a.judge ==true) count++;
}



int main()
{
	int N,i,count=0;
	scanf("%d",&N);
	for(i=0;i<N;i++)
	{
		scanf("%s %s",team[i].id,team[i].password);
	}
	for(i=0;i<N;i++)
	{
		jud(team[i],count);
	}
	
	if(count==0)
	{
		if(N==1)
		{
			printf("There is 1 account and no account is modified");
		}
		else 
		{
			printf("There are %d accounts and no account is modified",N);
		}
	}
	if(count!=0)
	{
		printf("%d\n",count);
		for(i=0;i<N;i++)
		{
			if(team[i].judge==true)
			{
				printf("%s %s\n",team[i].id,team[i].password);
			}
		}
	}
	return 0;
}

Sample Input 1:

3
Team000002 Rlsp0dfa
Team000003 perfectpwd
Team000001 R1spOdfa

Sample Output 1:

2
Team000002 RLsp%dfa
Team000001 R@spodfa

Sample Input 2:

1
team110 abcdefg332

Sample Output 2:

There is 1 account and no account is modified

Sample Input 3:

2
team110 abcdefg222
team220 abcdefg333

Sample Output 3:

There are 2 accounts and no account is modified

作者: CHEN, Yue

单位: PAT联盟

时间限制: 400ms

内存限制: 64MB

猜你喜欢

转载自blog.csdn.net/qq_42319613/article/details/81217918