【PAT】【Advanced Level】1035. Password (20)
来源:互联网 发布:gta5捏脸数据吴彦祖 编辑:程序博客网 时间:2024/06/03 20:06
1035. Password (20)
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
https://www.patest.cn/contests/pat-a-practise/1035
思路:
按要求处理
CODE:
#include<iostream>#include<cstring>#include<string>#include<vector>using namespace std;typedef struct S{ string name; string psw;};vector<S> vec;int main(){ int n; cin>>n; for (int i=0;i<n;i++) { string a,b; cin>>a>>b; int bo=0; for (int j=0;j<b.length();j++) { if (b[j]=='0') { b[j]='%'; } else if(b[j]=='O') { b[j]='o'; } else if(b[j]=='1') { b[j]='@'; } else if(b[j]=='l') { b[j]='L'; } else continue; bo=1; } if (bo==1) { S t; t.name=a; t.psw=b; vec.push_back(t); } } if (vec.size()==0) { if (n!=1) { cout<<"There are "<<n<<" accounts and no account is modified"; } else { cout<<"There is 1 account and no account is modified"; } } else { cout<<vec.size()<<endl; for (int i=0;i<vec.size();i++) cout<<vec[i].name<<" "<<vec[i].psw<<endl; } return 0;}
- 【c++】PAT (Advanced Level)1035. Password (20)
- 【PAT】【Advanced Level】1035. Password (20)
- PAT (Advanced Level) 1035. Password (20) 简单的字符串替换
- PAT (Advanced Level) 1035. Password (20) 解题报告
- [PAT (Advanced Level) ]1035. Password 解题文档
- PAT (Advanced Level) Practise 1035 Password (20)
- PAT (Advanced Level) Practise 1035 Password (20)
- PAT (Advanced) 1035. Password (20)
- 1035. Password (20)【字符串处理】——PAT (Advanced Level) Practise
- Pat(Advanced Level)Practice--1035(Password)
- 【PAT Advanced Level】1008. Elevator (20)
- 【PAT Advanced Level】1015. Reversible Primes (20)
- 【c++】PAT (Advanced Level)1008. Elevator (20)
- 【C++】PAT(advanced level)1061. Dating (20)
- PAT Advanced Level 1073. Scientific Notation (20)
- PAT Advanced Level 1077. Kuchiguse (20)
- 【PAT (Advanced Level)】1008. Elevator (20)
- 【PAT (Advanced Level)】1042. Shuffling Machine (20)
- 倒水
- C++队列
- 格局
- ubuntu 中jupyter notebook python2&3 并存使用
- C++函数的重载、内联和默认参数
- 【PAT】【Advanced Level】1035. Password (20)
- c++调用tensorflow教程
- 二十八天
- oracle彻底卸载
- Search in Rotated Sorted Array II问题及解法
- 【行为分析】(四)Introduce to ga.js(Legacy)
- Delphi7小工具,ParaDox 乱码处理
- vb.net 教程 3-6 窗体编程 打印
- C++类(持续更新中。。。)