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 题意: 假设二叉树中的所有键都是不同的正整数.一个唯一的二叉树可以通过给定的一对后序和顺序遍历序列来确定.这是一个简单的标准程序,可以按 ...
随机推荐
- linux学习(五)-----组管理和权限管理
Linux 组基本介绍 在 linux 中的每个用户必须属于一个组,不能独立于组外.在 linux 中每个文件有所有者.所在组.其它组的概念. 1)所有者 2)所在组 3)其它组 4)改变用户所在的组 ...
- System.Web.HttpCookie.cs
ylbtech-System.Web.HttpCookie.cs 1.程序集 System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken= ...
- idea运行tomcat,控制台中文乱码
加入参数:-Dfile.encoding=UTF-8
- PAT甲级——A1115 Counting Nodes in a BST【30】
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following propertie ...
- 19.SimLogin_case08
# 模拟登录微博 import time import base64 import rsa import binascii import requests import re import rando ...
- 使用CEfSharp之旅(7)CEFSharp 拦截 http 请求 websocket 内容
原文:使用CEfSharp之旅(7)CEFSharp 拦截 http 请求 websocket 内容 版权声明:本文为博主原创文章,未经博主允许不得转载.可点击关注博主 ,不明白的进群19106581 ...
- JPA默认方法查询遇到转JSON的处理
JPA提供的findAll等查询方法在有关联的对象时 比如:在查userInfo @Entity@Table(name = "user_info")public class Use ...
- 控制类名(className 属性)设置或返回class属性
控制类名(className 属性) className 属性设置或返回元素的class 属性. 语法: object.className = classname 作用: 1.获取元素的class 属 ...
- springboot2.0 使用aop实现PageHelper分页
参考: https://blog.csdn.net/qq_24076135/article/details/85212081 https://www.jianshu.com/p/036d31ae77d ...
- CodeForces-510D
https://vjudge.net/problem/CodeForces-510D题目可以转化为花最小代价选一些数,然后这些数可以经过加减运算得到1或-1,不然1你就凑不出来,一旦凑出来1,其他的都 ...