1.题目描述

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.
为了为PAT做准备,法官有时必须为用户生成随机密码。问题是总是有一些令人困惑的密码,因为很难区分1(1)和l(小写的L),或0(0)和O(大写的o)。一种解决方案是将1(1)替换为@,0替换为%,l替换为L,O替换为o。现在,您的工作是编写一个程序来检查法官生成的帐户,并帮助用户修改混淆的密码。

2.输入描述:

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.
每个输入文件包含一个测试用例。每一种情况都包含一个正整数N(<=1000),后面是N行帐户。每个帐户由用户名和密码组成,它们都是不超过10个字符的字符串,没有空格。

3.输出描述:

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.
对于每个测试用例,首先打印已修改的帐户号M,然后在以下M行中打印修改后的帐户信息,即用户名和相应的修改密码。这些帐户必须按照读入的顺序打印。如果没有修改帐户,在一行中打印“There are N accounts and no account is modified”,其中N是帐户的总数。然而,如果N是一个,你必须打印“There is 1 account and no account is modified”代替。

4.输入例子:

3
Team000002 Rlsp0dfa
Team000003 perfectpwd
Team000001 R1spOdfa

5.输出例子:

2
Team000002 RLsp%dfa
Team000001 R@spodfa

6.源代码:

#include<stdio.h>
#include<stdlib.h>
typedef struct
{
	int flag; //表示修改状态
	char User[11];
	char Pwd[11];
}Account;

int main()
{
	int N;
	scanf("%d", &N);
	
	Account *A;
	A=(Account *)malloc(N * sizeof(Account));

	int i, j,count=0;
	for(i = 0; i < N; i++)
	{
		scanf("%s %s", A[i].User, A[i].Pwd);

		A[i].flag = 0;//默认所有账户未被修改的状态

		for(j = 0; A[i].Pwd[j] != '\0'; j++)//遍历密码
		{
			switch(A[i].Pwd[j])//修改相应字符并记录修改状态
			{
				case '0':A[i].Pwd[j] = '%';A[i].flag=1;break;
				case '1':A[i].Pwd[j] = '@';A[i].flag=1;break;
				case 'l':A[i].Pwd[j] = 'L';A[i].flag=1;break;
				case 'O':A[i].Pwd[j] = 'o';A[i].flag=1;break;
				default:break;
			}
			
		}

		if(A[i].flag == 1)//计数修改的账户数量
				count++;
	}

	if(count != 0)//输出被修改的账户数和账户信息
	{
		printf("%d\n", count);
		for(i = 0; i < N; i++)
		{
			if(A[i].flag == 1)
				printf("%s %s\n", A[i].User, A[i].Pwd);
		}
	}
	else	//特殊情况的判断
		if(N == 1)
			printf("There is 1 account and no account is modified\n");		
		else
			printf("There are %d accounts and no account is modified\n", N);		
	return 0;
}