PAT 1035 password 翻译 分析 代码

28 篇文章 0 订阅
27 篇文章 0 订阅
#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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值