PAT甲级——A1035 Password
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 Nlines 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 <string>
#include <vector>
using namespace std;
int N;
int main()
{
cin >> N;
vector<pair<string, string>>res;
for (int i = ; i < N; ++i)
{
bool flag = false;
string name, password;
cin >> name >> password;
for (int j = ; j < password.length(); ++j)
{
if (password[j] == '')
{
flag = true;
password[j] = '@';
}
else if (password[j] == '')
{
flag = true;
password[j] = '%';
}
else if (password[j] == 'l')
{
flag = true;
password[j] = 'L';
}
else if (password[j] == 'O')
{
flag = true;
password[j] = 'o';
}
}
if (flag)
res.push_back(make_pair(name, password));
}
if (res.size() == )
{
if (N > )
cout << "There are " << N << " accounts and no account is modified" << endl;
else
cout << "There is " << N << " account and no account is modified" << endl;
}
else
{
cout << res.size() << endl;
for (auto ptr : res)
cout << ptr.first << " " << ptr.second << endl;
}
return ;
}
PAT甲级——A1035 Password的更多相关文章
- PAT 甲级 1035 Password (20 分)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...
- PAT 甲级 1035 Password
https://pintia.cn/problem-sets/994805342720868352/problems/994805454989803520 To prepare for PAT, th ...
- 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甲级题解(慢慢刷中)
博主欢迎转载,但请给出本文链接,我尊重你,你尊重我,谢谢~http://www.cnblogs.com/chenxiwenruo/p/6102219.html特别不喜欢那些随便转载别人的原创文章又不给 ...
- A1035 Password (20)(20 分)
A1035 Password (20)(20 分) To prepare for PAT, the judge sometimes has to generate random passwords f ...
- PAT甲级代码仓库
大道至简,知易行难.希望能够坚持刷题. PAT甲级真题题库,附上我的代码. Label Title Score Code Level 1001 A+B Format 20 1001 * 1002 A+ ...
- PAT甲级1131. Subway Map
PAT甲级1131. Subway Map 题意: 在大城市,地铁系统对访客总是看起来很复杂.给你一些感觉,下图显示了北京地铁的地图.现在你应该帮助人们掌握你的电脑技能!鉴于您的用户的起始位置,您的任 ...
- PAT甲级1127. ZigZagging on a Tree
PAT甲级1127. ZigZagging on a Tree 题意: 假设二叉树中的所有键都是不同的正整数.一个唯一的二叉树可以通过给定的一对后序和顺序遍历序列来确定.这是一个简单的标准程序,可以按 ...
随机推荐
- grunt是什么
Grunt是什么? 博客分类: Grunt GruntJavascript Grunt是一个自动化的项目构建工具.如果你需要重复的执行像压缩,编译,单元测试,代码检查以及打包发布的任务.那么你可以使 ...
- VS2010-MFC(常用控件:编辑框Edit Control)
转自:http://www.jizhuomi.com/software/181.html 编辑框(Edit Control)是一种很常用的控件,我们可以在编辑框中输入并编辑文本.在前面加法计算器的例子 ...
- 框架:Flutter(移动应用程序开发框架)
ylbtech-框架:Flutter(移动应用程序开发框架) Flutter是谷歌的移动UI框架,可以快速在iOS和Android上构建高质量的原生用户界面. Flutter可以与现有的代码一起工作. ...
- 样本方差的抽样分布 χ2(n) 卡方分布_样本方差 卡方分布
样本方差的抽样分布 χ2(n) 卡方分布_样本方差 卡方分布 样本方差的抽样分布 χ2(n) 卡方分布 t分布.卡方分布.f分布均要求总体服从正态分布. 若n个相互独立的随机变量ξ1,ξ2,-,ξn ...
- Mysql优化系列之查询优化干货1
从这一篇开始,准备总结一些直接受用的sql语句优化,写sql是第二要紧的,第一要紧的,是会分析怎么查最快, 因为当你写过很多sql后,查询出结果已经不是目标,快,才是目标.另外,通过测试和比较的结果才 ...
- 用Navicat for mysql连接mysql报错1251-解决办法
今天下了个 MySQL8.0,发现Navicat连接不上,总是报错1251: 原因是MySQL8.0版本的加密方式和MySQL5.0的不一样,连接会报错. 试了很多种方法,终于找到一种可以实现的: 更 ...
- vue 返回上一页
参考:https://www.cnblogs.com/chenguiya/p/9118265.html 注:需为history模式 方法一: @click="back" back( ...
- more 和less 命令简单介绍以及使用
一.more命令 more功能类似 cat ,cat命令是整个文件的内容从上到下显示在屏幕上. more会以一页一页的显示方便使用者逐页阅读,而最基本的指令就是按空白键(space)就往下一页显示,按 ...
- 记录一次工作中配置的Mysql主从复制过程
Mysql主从复制教程 1.安装mysql(安装步骤跳过)2.配置密码.(如果忘记密码或者误操作删除了root用户,使用如下命令,没有忘记就跳到3)将skip-grant-tables放在/etc/m ...
- 搭建react的vw架构时候报 Cannot load preset "advanced".
原版的报错如下 Administrator@DESKTOP-EHCTIOR MINGW64 /e/821box/react-vw-layout (master) $ yarn start yarn r ...