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 ...
随机推荐
- Deepin 系统下设置Apache虚拟主机站点
1,在 var/www/html 文件夹中创建一个文件夹,命名为 a ,用来作为我们的PHP项目文件夹. 2,找到 etc/apache2/sites-available 文件夹,在文件夹中创建一个站 ...
- mybaits<set>标签的使用
使用set标签可以将动态的配置SET 关键字,和剔除追加到条件末尾的任何不相关的逗号 1.在接口中创建方法 public void updateEmp(Employee employee); 2在映射 ...
- input 输入框效验
input 输入框效验 1:只能输入正整数: <el-input v-model.number="formData.projectNum" type='number' min ...
- Git:目录
ylbtech-Git:目录 1.返回顶部 1. https://git-scm.com/ 2. 2.返回顶部 1.Easy Git Integration Tools https://marketp ...
- JS中keyup, keypress, keydown以及oninput四个事件的区别
$email_input.onkeyup=function(event){ // console.log('event handle');//按方向键以及backspce esc有反应 长按字母键也没 ...
- Mysql的caching_sha2_password的坑
概述 今天我用homebrew安装Mysql8.0,安装完成之后,用Workbench和Sequel Pro连接数据库都失败了,并且都报caching_sha2_password相关的错误,经过查资料 ...
- Linux centos 解决"不在 sudoers 文件中。此事将被报告"的问题
第一部分讲解如何从普通用户到root用户 网上看了很多,其实就是执行 su root ,然后输入当前用户密码,这个时候可能报错 这个问题不大,执行一下提示的语句: abrt-auto-reportin ...
- 设置了responseType:Blob之后,如果返回json错误信息,如果获取?
最近做了一个文件下载功能,于是设置了responseType: Blob的方式, 什么是Blob呢,MDN官方解释:Blob 对象表示一个不可变.原始数据的类文件对象.Blob 表示的不一定是Java ...
- 【Spring】---【AOP】
转发几篇文章 专治不会看源码的毛病--spring源码解析AOP篇 Spring3:AOP 理解AOP 什么是AOP? 转自: http://www.cnblogs.com/xiexj/p/73668 ...
- Java本周总结1
这两周我上认真的课应该就是李老师的课了/ 第一周主要跟我们讲述了java的发展史何java开发环境的搭建,带领我们走进了java,李老师的精彩讲述让我们对Java有了深刻的认识/. jdk下载安装包我 ...