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

题意:

  给出一组用户的密码,按照要求替换密码中的字符。

思路:

  模拟。

Code:

 1 #include <bits/stdc++.h>
2
3 using namespace std;
4
5 struct User {
6 string name;
7 string password;
8 };
9
10 int main() {
11 int n;
12 cin >> n;
13 map<char, char> mp;
14 mp['1'] = '@';
15 mp['0'] = '%';
16 mp['l'] = 'L';
17 mp['O'] = 'o';
18 vector<User> res;
19 for (int i = 0; i < n; ++i) {
20 string name, password;
21 cin >> name >> password;
22 bool found = false;
23 for (int j = 0; j < password.length(); ++j) {
24 if (mp.find(password[j]) != mp.end()) {
25 password[j] = mp[password[j]];
26 found = true;
27 }
28 }
29 if (found) res.push_back({name, password});
30 }
31 if (res.size() == 0) {
32 if (n == 1)
33 cout << "There is " << n << " account and no account is modified"
34 << endl;
35 else
36 cout << "There are " << n << " accounts and no account is modified"
37 << endl;
38 } else {
39 cout << res.size() << endl;
40 for (auto it : res) cout << it.name << " " << it.password << endl;
41 }
42
43 return 0;
44 }

注意:

  注意第三人称单数和名词复数的使用方法。

1035 Password的更多相关文章

  1. PAT 甲级 1035 Password (20 分)

    1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...

  2. PAT 1035 Password

    1035 Password (20 分)   To prepare for PAT, the judge sometimes has to generate random passwords for ...

  3. 1035 Password (20 分)

    1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...

  4. PAT 1035 Password [字符串][简单]

    1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...

  5. pat 1035 Password(20 分)

    1035 Password(20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the ...

  6. PAT 甲级 1035 Password (20 分)(简单题)

    1035 Password (20 分)   To prepare for PAT, the judge sometimes has to generate random passwords for ...

  7. PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642

    PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...

  8. 【PAT】1035. Password (20)

    题目:http://pat.zju.edu.cn/contests/pat-a-practise/1035 分析:简单题.直接搜索,然后替换,不会超时,但是应该有更好的办法. 题目描述: To pre ...

  9. 1035 Password (20)

    #include <stdio.h> #include <string.h> struct MyStruct { ]; ]; bool changed; }; int main ...

  10. 1035 Password (20)(20 point(s))

    problem To prepare for PAT, the judge sometimes has to generate random passwords for the users. The ...

随机推荐

  1. Prism -- 简介

    Prism是一个开源框架,用于在WPF.Xamarin Forms.Uno/Win UI等应用中创建松耦合.可维护.可测试的XAML应用程序.Prism提供了一组设计模式的实现,这些设计模式有助于编写 ...

  2. EFCodeFirst关系映射约定

    EFCodeFirst关系映射约定 EFCodeFirst 关系映射约定 默认多重关系的一些约定规则: 1.一对多关系 两个类中分别包含一个引用和一个集合属性. 两个类中一个类包含另一个类的引用属性. ...

  3. Arrays.Sort()中的那些排序算法

    本文基于JDK 1.8.0_211撰写,基于java.util.Arrays.sort()方法浅谈目前Java所用到的排序算法,仅个人见解和笔记,若有问题欢迎指证,着重介绍其中的TimSort排序,其 ...

  4. 剑指 Offer 39. 数组中出现次数超过一半的数字 + 摩尔投票法

    剑指 Offer 39. 数组中出现次数超过一半的数字 Offer_39 题目描述 方法一:使用map存储数字出现的次数 public class Offer_39 { public int majo ...

  5. js导出execl 兼容ie Chrome Firefox各种主流浏览器(js export execl)

    第一种导出table布局的表格 1 <html> 2 3 <head> 4 <meta charset="utf-8"> 5 <scrip ...

  6. 记离线部署docker,以及docker下部署zabbix

    一.离线安装docker 下载地址:https://download.docker.com/linux/static/stable/x86_64/ 上传软件并解压 [root@localhost op ...

  7. 【Arduino学习笔记04】消抖动的按键切换

    "开关抖动": 由于按键是基于弹簧-阻尼系统的机械部件,所以当按下一个按键时,读到的信号并不是从低到高,而是在高低电平之间跳动几毫秒之后才最终稳定. 代码解读: 1 const i ...

  8. Nmap命令使用方法

          Nmap使用合集 感谢博主:VVVinson    文章链接:https://www.cnblogs.com/Vinson404/p/7784829.html 参    数 说    明 ...

  9. 2018.12-2019.1 TO-DO LIST

    AC自动机 P3808 [模板]AC自动机(简单版)(完成时间:2018.12.06) P3796 [模板]AC自动机(加强版)(完成时间:2018.12.06) P2444 [POI2000]病毒( ...

  10. java集合框架部分相关接口与类的介绍

    集合基础 接口 Iterable //Implementing this interface allows an object to be the target of the "for-ea ...