Pat(Advanced Level)Practice--1035(Password)
来源:互联网 发布:学生基本信息表sql 编辑:程序博客网 时间:2024/06/06 00:46
Pat1035代码
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<cstring>#define MAX 1005using namespace std;typedef struct user{char accounts[15];char password[15];int flag;}User;int main(int argc,char *argv[]){int i,j;User u[MAX];int n,m;scanf("%d",&n);for(i=0;i<n;i++){scanf("%s %s",u[i].accounts,u[i].password);u[i].flag=0;}int count=0;for(i=0;i<n;i++){for(j=0;u[i].password[j]!='\0';j++){if(u[i].password[j]=='1'){u[i].password[j]='@';u[i].flag=1;}if(u[i].password[j]=='0'){u[i].password[j]='%';u[i].flag=1;}if(u[i].password[j]=='l'){u[i].password[j]='L';u[i].flag=1;}if(u[i].password[j]=='O'){u[i].password[j]='o';u[i].flag=1;}}if(u[i].flag==1)count++;}if(count==0){if(n<2)printf("There is 1 account and no account is modified\n");elseprintf("There are %d accounts and no account is modified\n",n);}else {printf("%d\n",count);for(i=0;i<n;i++)if(u[i].flag)printf("%s %s\n",u[i].accounts,u[i].password);}return 0;}
- Pat(Advanced Level)Practice--1035(Password)
- PAT (Advanced Level) Practise 1035 Password (20)
- PAT (Advanced Level) Practise 1035 Password (20)
- PAT (Advanced Level) Practice 1006
- Pat(Advanced Level)Practice--1025(PAT Ranking)
- Pat(Advanced Level)Practice--1075(PAT Judge)
- Pat(Advanced Level)Practice--1003(Emergency)
- Pat(Advanced Level)Practice--1004(Counting Leaves)
- Pat(Advanced Level)Practice--1008(Elevator)
- Pat(Advanced Level)Practice--1010(Radix)
- Pat(Advanced Level)Practice--1015(Reversible Primes)
- Pat(Advanced Level)Practice--1024(Palindromic Number)
- Pat(Advanced Level)Practice--1028(List Sorting)
- Pat(Advanced Level)Practice--1029(Median)
- Pat(Advanced Level)Practice--1030(Travel Plan)
- Pat(Advanced Level)Practice--1037(Magic Coupon)
- Pat(Advanced Level)Practice--1032(Sharing)
- Pat(Advanced Level)Practice--1041(Be Unique)
- String中==和equal()的区别
- HDU 4165Pills
- Servlet分析(3) servletRequest与 servletResponse
- 我写过的软件之LoaderHst-TestView
- 读写Excel文件最好还是用Office VBA之类的,C++读写原来这么不容易
- Pat(Advanced Level)Practice--1035(Password)
- 计算机考研
- com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax;
- 机房收费系统-状态图与活动图
- ASP.NE连接Access数据库
- Eclipse 3.2 + MyEclipse 5.0GA + WebLogic 9.2
- linux入门
- LeetCode Reverse Words in a String Total
- shell中的more命令