1035. Password (20)
来源:互联网 发布:真丝枕套 知乎 编辑:程序博客网 时间:2024/04/30 06:13
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
分析:
(1)建立结构体,中间有个字符比较,记录好一些标着;
(2)小心文字游戏。。。is are 还有复数。。。。
#include <string>#include <iostream>using namespace std;struct account {string id;string pw;int flag;};int main (){int N,i,j;cin>>N;account *ps= new account[N];for (i=0;i<N;i++){cin>>ps[i].id;cin>>ps[i].pw;ps[i].flag=0;} int mFlag=0;for (i=0;i<N;i++){j=0;while (ps[i].pw[j]!='\0'){if (ps[i].pw[j]=='1'){ps[i].pw[j]='@';ps[i].flag=1;}else if (ps[i].pw[j]=='0'){ps[i].pw[j]='%';ps[i].flag=1;}else if (ps[i].pw[j]=='l'){ps[i].pw[j]='L';ps[i].flag=1;}else if (ps[i].pw[j]=='O'){ps[i].pw[j]='o';ps[i].flag=1;}j++;}if (ps[i].flag==1){mFlag++;}}if (mFlag==0){if(N<=1)cout<<"There is "<<N<<" account and no account is modified";else cout<<"There are "<<N<<" accounts and no account is modified";}else {cout<<mFlag<<endl;for (i=0;i<N;i++){if (ps[i].flag==1){cout<<ps[i].id<<" "<<ps[i].pw<<endl;}}} delete [] ps;return 0;}
- 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)
- C语言读取BMP图像数据(转)
- Thumb指令集与ARM指令集的区别
- Android-telephony各文件解释
- Eclipse 高亮配置仿Apple养眼
- sql执行顺序
- 1035. Password (20)
- 【面试】程序员:下一次面试前你需要准备的五个基本步骤
- 虚拟机下的Linux自动获取IP地址
- prime distance
- VS2010使用videoinput时出现无法打开atlthunk.lib文件解决办法
- Java多线程之CyclicBarrier
- jQuery性能优化指南
- Java多线程之CountDownLatch
- 50道Java习题之02