1035. Password (20)
来源:互联网 发布:java 为何工资高 编辑:程序博客网 时间:2024/06/07 01:16
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:
3Team000002 Rlsp0dfaTeam000003 perfectpwdTeam000001 R1spOdfaSample Output 1:
2Team000002 RLsp%dfaTeam000001 R@spodfaSample Input 2:
1team110 abcdefg332Sample Output 2:
There is 1 account and no account is modifiedSample Input 3:
2team110 abcdefg222team220 abcdefg333Sample Output 3:
There are 2 accounts and no account is modified
-------------华丽的分割线------------------
分析:用一个全局变量来统计修正了的个数
代码:
#include<cstdio>#include<cstdlib>#include<cstring>#define Maxn 1001typedef struct{char teamnum[11];char password[11];bool needModify;}Stu;Stu input[Maxn];bool convert(int i);int Sum=0;int main(void){int N;scanf("%d",&N);int i;for(i=0;i<N;++i){scanf("%s %s",input[i].teamnum,input[i].password);convert(i);}if(Sum){printf("%d\n",Sum);for(i=0;i<N;++i){if(input[i].needModify){printf("%s %s\n",input[i].teamnum,input[i].password);}}}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);}}system("pause");return 0;}bool convert(int i){bool modified = false;int length = strlen(input[i].password);for(int j=0;j<length;++j){if(input[i].password[j] == '1'){input[i].password[j] = '@';modified = true;}if(input[i].password[j] == '0'){input[i].password[j] = '%';modified = true;}if(input[i].password[j] == 'l'){input[i].password[j] = 'L';modified = true;}if(input[i].password[j] == 'O'){input[i].password[j] = 'o';modified = true;}}if(modified){input[i].needModify = true;++Sum;}return modified;}
- 1035. Password (20)
- 【PAT】1035. Password (20)
- 1035. Password (20)-PAT
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- PAT 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- 1035. Password (20)
- pat 1035. Password (20)
- BeanUtils.copyProperties与PropertyUtils.copyProperties用法及区别(转)
- 对前台传过来的json对象或数组进行转化
- RMI与Hession使用
- [Android]打开eclipse报错:发现了以元素 'd:skin' 开头的无效内容。此处不应含有子元素。
- JAVA多线程实现的三种方式
- 1035. Password (20)
- ViewAnimator及其子类
- 市航天纪念钞 出门就升值
- hadoop常见错误整理
- 【Protobuf】
- 微信自定义推送模版消息
- 1041. Be Unique (20)
- Hive部署安装时,Specified key was too long; max key length is 767 bytes
- android应用性能测试之CPU和内存占用