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. webpack + vuecli多页面打包基于(vue-template-admin)修改

    转: webpack + vuecli多页面打包基于(vue-template-admin)修改 遇见的问题TypeError: Cannot read property 'tap' of undef ...

  2. 漏洞复现-CVE-2015-1427-Groovy远程代码执行

          0x00 实验环境 攻击机:Win 10 靶机也可作为攻击机:Ubuntu18 (docker搭建的vulhub靶场) 0x01 影响版本 Elasticsearch 1.3.0-1.3. ...

  3. redis一句话木马控电脑

      (1)在redis管理工具内写入木马并保存: 输入命令行: config set dbfilename shell.php set shell "<?php @assert($_P ...

  4. 使用jhipster 加速java web开发

    jhipster,中文释义: Java 热爱者! JHipster is a development platform to quickly generate, develop, & depl ...

  5. python之模块与类库

    什么是模块 模块是一组类,函数,方法所组成的.这些类都储存在文本文件中..py是python程序代码中的扩展名,模块可能是c或者python写的.模块的扩展名可以是.py或者是.pyc(经过编译的.p ...

  6. [差分][二分][贪心]luogu P3634 [APIO2012]守卫

    题面 https://www.luogu.com.cn/problem/P3634 给m个限制,可以是一段区间中必须有或者必须无忍者 最多有k个忍者,问有多少个位点一定有忍者 分析 首先用差分标记一下 ...

  7. 菜刀jsp小马

    逛google收获小马一枚,收藏一下 <%@page import="java.io.*,java.util.*,java.net.*,java.sql.*,java.text.*&q ...

  8. Ubuntu-搭建Clang Static Analyzer环境

    其实也就是一个开源的漏洞扫描器 专门扫描C/C++ 0BJECT-C++这种,实不相瞒我搭建了5天这个环境,最后我发现了一种超级方便的办法 前面怎么走的坑还是不分享了吧,由于没有看到前面很多人的办法或 ...

  9. Java中的IO流 - 入门篇

    前言 大家好啊,我是汤圆,今天给大家带来的是<Java中的IO流-入门篇>,希望对大家有帮助,谢谢 由于Java的IO类有很多,这就导致我刚开始学的时候,感觉很乱,每次用到都是上网搜,结果 ...

  10. 使用 Github Actions artifact 在 workflow job 之间共享数据

    (AgileConfig)[https://github.com/kklldog/AgileConfig] 在使用 react 编写UI后,变成了一个彻彻底底的前后端分离的项目,上一次解决了把reac ...