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 ...
随机推荐
- 【Python】学习笔记五:缩进与选择
Python最具特色的用缩进来标明成块的代码 缩进 i = 4 j = 2 if i > j: i = i+1 print(i) 这是一个简单的判断,Python的if使用很简单,没有括号等繁琐 ...
- python 正则之字母匹配
\A:匹配字符串的开始 \b:匹配一个单词边界 取出a边界单词的个数 >>> len(re.findall(r"\ba"," ab abc ad ...
- linux 目录介绍
/boot: 系统启动相关的文件,如内核.initrd,以及grub(bootloader)/dev: 设备文件 /etc:配置文件/home:用户的家目录,每一个用户的家目录通常默认为/home/U ...
- 图的深度优先搜索(DFS)和广度优先搜索(BFS)算法
深度优先(DFS) 深度优先遍历,从初始访问结点出发,我们知道初始访问结点可能有多个邻接结点,深度优先遍历的策略就是首先访问第一个邻接结点,然后再以这个被访问的邻接结点作为初始结点,访问它的第一个邻接 ...
- libusb获取usb设备的idVendor(vid),idProduct(pid),以及Serial Number
发表于2015/6/23 21:55:11 4594人阅读 最近在做关于usb设备的项目,用到了libusb,发现关于这个的函数库的介绍,讲解很少,下面仅仅是简单展示一些基本的使用方法,以备后用. ...
- iOS UICollectionView数据少导致不能滚动
有时候UICollectionView会遇到不能滑动的情况,但是我们并没有代码明确禁止这个东西的滑动效果,这个是苹果系统的小漏洞. 解决办法: 横向滑动的 collectionView.alwaysB ...
- 关于db4o的透明激活与激活声明
关于db4o的透明激活与激活声明 有关于透明激活,其介绍可以参看这里:http://www.cnblogs.com/redmoon/archive/2008/02/23/1078619.html 文中 ...
- SSLPinning简介,使用Xposed+JustTrustMe来突破SSL Pinning
0x00 前面 如果你是一干Web安全的,当你在测试目前大多数的手机APP应用程序时,你一定遇到过burpsuite无法抓到数据包的情况,开始你以为只是https的问题,但是当你使用了burpsuit ...
- Matlab——程序设计
M文件 我们之前所做的运算————> 算式不太长,或想以交谈式方式进行运算 如果算式很长或是需要一再执行的算式————> 采用M文件的方式 [将指令及算式写成巨集程式然后储存成一个特别的文 ...
- django groupby 用法