PAT Advanced 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 (≤), 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
#include<iostream>
#include<vector>
using namespace std;
struct user{
string id;
string pw;
};
int main() {
int T;
cin>>T;
user tmp;
vector<user> vec;
bool isConfused=false;
for(int i=;i<T;i++){
isConfused=false;
cin>>tmp.id>>tmp.pw;
for(int i=;i<tmp.pw.length();i++){
switch(tmp.pw[i]){
case '':
tmp.pw[i]='@';
isConfused=true;
break;
case '':
tmp.pw[i]='%';
isConfused=true;
break;
case 'l':
tmp.pw[i]='L';
isConfused=true;
break;
case 'O':
tmp.pw[i]='o';
isConfused=true;
break;
}
}
if(isConfused) vec.push_back(tmp);
}
if(vec.size()==) {
if(T==) printf("There is 1 account and no account is modified");
else printf("There are %d accounts and no account is modified",T);
/**需要注意account和accounts是不一样的*/
}
else{
cout<<vec.size()<<endl;
for(int i=;i<vec.size();i++){
cout<<vec[i].id<<" "<<vec[i].pw<<endl;
}
}
system("pause");
return ;
}
PAT Advanced 1035 Password (20 分)的更多相关文章
- PAT 甲级 1035 Password (20 分)(简单题)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for ...
- PAT甲级——1035 Password (20分)
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...
- PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642
PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...
- PAT (Advanced Level) Practice 1035 Password (20 分)
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...
- 【PAT甲级】1035 Password (20 分)
题意: 输入一个正整数N(<=1000),接着输入N行数据,每行包括一个ID和一个密码,长度不超过10的字符串,如果有歧义字符就将其修改.输出修改过多少组密码并按输入顺序输出ID和修改后的密码, ...
- 【PAT】1035. Password (20)
题目:http://pat.zju.edu.cn/contests/pat-a-practise/1035 分析:简单题.直接搜索,然后替换,不会超时,但是应该有更好的办法. 题目描述: To pre ...
- 1035 Password (20分)(水)
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...
- PAT Advanced 1008 Elevator (20 分)
The highest building in our city has only one elevator. A request list is made up with N positive nu ...
- PAT Advanced 1077 Kuchiguse (20 分)
The Japanese language is notorious for its sentence ending particles. Personal preference of such pa ...
随机推荐
- windows7 中 wacom数位板如何关闭点击水波 和长按右键这两个特效
就是点住笔尖不动,就会弹出右键,这个功能是微软操作系统具有的一项功能,,如果您感觉不便,可以按以下方法将其去掉: 1.打开"控制面板--笔和触摸--笔选项--按下并保持--设置": ...
- Vue中 v-bind和v-on 缩写
v-bind 缩写 <!-- 完整语法 --> <a v-bind:href="url">...</a> <!-- 缩写 --> & ...
- 线下作业MySQL #20175201
1.下载附件中的world.sql.zip, 参考http://www.cnblogs.com/rocedu/p/6371315.html#SECDB,导入world.sql,提交导入成功截图 2.编 ...
- 打造boost的trhead环境
windows下的环境 1.官网下载boost_1_68_0解压后用VS2010的命令行工具运行bootstrap.bat 2.用VS2005命令行工具运行 bjam.exe link=static ...
- ffmpeg精简编译
项目上需要用到ffmpeg的接收功能,把rtp流转封装为ts吐udp组播流,不涉及编码,所以需要精简一下脚本如下: #!/bin/bash dir=$(pwd) echo $dir rm -rf $d ...
- leetcode-mid-sorting and searching-34 Search for a Range
mycode 63.98% class Solution(object): def searchRange(self, nums, target): """ :typ ...
- ubuntu 18.04 gcc g++降级4.8版
$ sudo apt-get install -y gcc-4.8 $ sudo apt-get install -y g++-4.8 $ cd /usr/bin $ sudo rm gcc $ su ...
- RF通过命令执行用例及自定义报告与日志的位置
1.执行整个项目下的所有用例: pybot 项目路径.例如: pybot D:\robotPS:robot项目里面所有用例 2.执行某个suit中的所有用例: pybot 项目路径\suit文件名称. ...
- python - 简单化list的 For[if] 语句
python的list数据 >>>a=[, , , , , , ] >>>b=a >>>b [, , , , , , ] 用这种方式将a.list ...
- mysql数据库连接错误10060
今天在使用mysql数据库的时候,出现错误ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10060) 我在网上一顿 ...