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 题意: 假设二叉树中的所有键都是不同的正整数.一个唯一的二叉树可以通过给定的一对后序和顺序遍历序列来确定.这是一个简单的标准程序,可以按 ...
随机推荐
- iOS开发NSLayoutConstraint代码自动布局
1.NSLayoutConstraint简介 适配界面大多用Masonry工具,也是基于NSLayoutConstraint写的!通过使用两个类方法实现自动布局: + (NSArray<__ki ...
- 如何用excel统计调查问卷
如何用excel统计调查问卷 有些人可能经常要对调查问卷进行统计,使用手写的方法(就是在纸上写正字的方法)虽然很方便,不过不方便在一定条件下进行统计,如在男士的条件下,使用诺基亚的手机有多少人.而用e ...
- 常用终止python程序方法
方法1:采用sys.exit(0)正常终止程序,从图中可以看到,程序终止后shell运行不受影响. 方法2:采用os._exit(0)关闭整个shell,从图中看到,调用sys._exit(0)后整个 ...
- loj6031「雅礼集训 2017 Day1」字符串
题目 首先先对\(s\)建一个\(\operatorname{SAM}\),设\(w=kq\) 发现\(k,q\leq 10^5\),但是\(w\leq 10^5\),于是套路地根号讨论一下 如果\( ...
- P3338 [ZJOI2014]力 /// FFT 公式转化翻转
题目大意: https://www.luogu.org/problemnew/show/P3338 题解 #include <bits/stdc++.h> #define N 300005 ...
- springboot2.0 使用aop实现PageHelper分页
参考: https://blog.csdn.net/qq_24076135/article/details/85212081 https://www.jianshu.com/p/036d31ae77d ...
- python3 selenium 超时停止加载,并且捕捉异常, 进行下一步【亲测有效】
from selenium import webdriver import os import re class GetPage: def __init__(self, url_path): self ...
- DMZ在虚拟化环境中的部署
常见的方法有三种: 1.分别部署 2.部分虚拟化 3.全部虚拟化 传统DMZ部署结构: 分别部署: 想要保持DMZ区域物理隔离采用这种方法,每个区域分别部署进入不同的服务器集群,区域之间的连接采用物理 ...
- Servlet3.0要点小结
1. 注解配置Servlet @WebServlet name属性: servlet名称 value属性或urlPatterns属性: servlet映射路径, 可配置多个 initParams属性: ...
- 拦截器和自定义注解@interface
1 .拦截器(Interceptor): 用于在某个方法被访问之前进行拦截,然后在Handler执行之前或之后加入某些操作,其实就是AOP的一种实现策略. 拦截用户的请求并进行相应的处理,比如:判断用 ...