欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

pat1035. Password (20)

发布时间:2024/4/17 编程问答 46 豆豆
生活随笔 收集整理的这篇文章主要介绍了 pat1035. Password (20) 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

1035. Password (20)

时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue

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

提交代码

 

1 #include<cstdio> 2 #include<stack> 3 #include<algorithm> 4 #include<iostream> 5 #include<stack> 6 #include<set> 7 #include<map> 8 #include<vector> 9 using namespace std; 10 vector<string> v; 11 map<string,string> ha; 12 bool check(char &c){ 13 if(c=='1'){ 14 c='@'; 15 return true; 16 } 17 if(c=='0'){ 18 c='%'; 19 return true; 20 } 21 if(c=='l'){ 22 c='L'; 23 return true; 24 } 25 if(c=='O'){ 26 c='o'; 27 return true; 28 } 29 return false; 30 } 31 int main(){ 32 //freopen("D:\\INPUT.txt","r",stdin); 33 int n; 34 scanf("%d",&n); 35 int i,j; 36 string num,pas; 37 int count=0; 38 for(i=0;i<n;i++){ 39 cin>>num>>pas; 40 bool can=false; 41 for(j=0;j<pas.length();j++){ 42 if(check(pas[j])){ 43 can=true; 44 } 45 } 46 if(can){ 47 count++; 48 v.push_back(num); 49 ha[num]=pas; 50 } 51 } 52 if(count){ 53 printf("%d\n",count); 54 for(j=0;j<v.size();j++){ 55 cout<<v[j]<<" "<<ha[v[j]]<<endl; 56 } 57 } 58 else{ 59 if(n==1){ 60 printf("There is 1 account and no account is modified\n",n); 61 } 62 else{ 63 printf("There are %d accounts and no account is modified\n",n); 64 } 65 } 66 return 0; 67 }

 

转载于:https://www.cnblogs.com/Deribs4/p/4782220.html

总结

以上是生活随笔为你收集整理的pat1035. Password (20)的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。