PATA1035 Password

举报
陈沧夜 发表于 2022/04/30 00:23:04 2022/04/30
【摘要】 1035 Password To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords sinc...

1035 Password

To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L in lowercase), or 0 (zero) from O (o in uppercase). One solution is to replace 1 (one) by @0 (zero) by %l by L, and O by o. Now it is your job to write a program to check the accounts generated by the judge, and to help the juge modify the confusing passwords.

Input Specification:

Each input file contains one test case. Each case contains a positive integer N (≤1000), followed by N lines of accounts. Each account consists of a user name and a password, both are strings of no more than 10 characters with no space.

Output Specification:

For each test case, first print the number M of accounts that have been modified, then print in the following M lines the modified accounts info, that is, the user names and the corresponding modified passwords. The accounts must be printed in the same order as they are read in. If no account is modified, print in one line There are N accounts and no account is modified where N is the total number of accounts. However, if N is one, you must print There is 1 account and no account is modified instead.

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

 

 #include<cstdio>
 #include<iostream>
 #include<cstring>
 using namespace std;
  
  
struct Users{
	char num[20];
	char pass[20];
	bool flag = false;
}user[1005];
int main()
  
  {
  	int N; 
  	int sum=0;
  	scanf("%d",&N);
  	int i,j;
  	for(i=0;i<N;i++)
  	{
  		scanf("%s %s",user[i].num,user[i].pass);
  		for( j=0;j<strlen(user[i].pass);j++)
  		{
  			if(user[i].flag!=true)
  			{
  			if(user[i].pass[j]=='1') {user[i].pass[j]='@';user[i].flag=true;break;}
  			if(user[i].pass[j]=='0') {user[i].pass[j]='%';user[i].flag=true;break;}
  			if(user[i].pass[j]=='l') {user[i].pass[j]='L';user[i].flag=true;break;}
  			if(user[i].pass[j]=='O') {user[i].pass[j]='o';user[i].flag=true;break;}
  			
			  }
			if(user[i].flag==true)
			{
				sum++;
				break;
			}

			
		  }
	  }
	  
  	if(sum)
  	{
  		printf("%d",sum);
  		for(int i=0;i<N;i++)
  		{
  			if(user[i].flag==true)
  			{
  			printf("\n");
  			printf("%s %s",user[i].num,user[i].pass);	
			  }

		  }
	  }
	  else
	  {
	  	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);
		  }
	  }
   } 

 

文章来源: blog.csdn.net,作者:沧夜2021,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/CANGYE0504/article/details/88836280

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。