1035 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 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的更多相关文章
- PAT 甲级 1035 Password (20 分)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...
- PAT 1035 Password
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for ...
- 1035 Password (20 分)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...
- PAT 1035 Password [字符串][简单]
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...
- pat 1035 Password(20 分)
1035 Password(20 分) To prepare for PAT, the judge sometimes has to generate random passwords for the ...
- PAT 甲级 1035 Password (20 分)(简单题)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for ...
- PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642
PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...
- 【PAT】1035. Password (20)
题目:http://pat.zju.edu.cn/contests/pat-a-practise/1035 分析:简单题.直接搜索,然后替换,不会超时,但是应该有更好的办法. 题目描述: To pre ...
- 1035 Password (20)
#include <stdio.h> #include <string.h> struct MyStruct { ]; ]; bool changed; }; int main ...
- 1035 Password (20)(20 point(s))
problem To prepare for PAT, the judge sometimes has to generate random passwords for the users. The ...
随机推荐
- WPF -- 一种圆形识别方案
本文介绍一种圆形的识别方案. 识别流程 判断是否为封闭图形: 根据圆的方程,取输入点集中的1/6.3/6.5/6处的三个点,求得圆的方程,获取圆心及半径: 取点集中的部分点,计算点到圆心的距离与半径的 ...
- C++核心篇
C++核心编程 本阶段主要针对C++面向对象编程技术做详细讲解,探讨C++中的核心和精髓. 1 内存分区模型 C++程序在执行时,将内存大方向划分为4个区域 代码区:存放函数体的二进制代码,由操作系统 ...
- 心脏滴血(CVE-2014-0160)检测与防御
用Nmap检测 nmap -sV --script=ssl-heartbleed [your ip] -p 443 有心脏滴血漏洞的报告: ➜ ~ nmap -sV --script=ssl-hear ...
- sqlyog如何增删改查?
转: sqlyog如何增删改查? 下面是一道完整的 sqlyog 增删改查的练习, 顺着做下去,可以迅速掌握. 1. 创建部门表dept,并插入数据: 2. 创建emp员工表,并插入数据: sql 代 ...
- pytorch(11)模型创建步骤与nn.Module
模型创建与nn.Module 网络模型创建步骤 nn.Module graph LR 模型 --> 模型创建 模型创建 --> 构建网络层 构建网络层 --> id[卷积层,池化层, ...
- Java I/O流 02
IO流·字节流 IO流概述及其分类 * A:概念 * IO流用来处理设备之间的数据传输 * Java对数据的操作是通过流操作的 * Java用于操作流的类都在IO包中 * 流按流向分为两种输入流.输出 ...
- PyCharm之python package和directory的区别
python作为一门解释性的脚本语言.python中模块就是指一个py文件,如果我们将所有相关的代码都放在一个py文件中,则该py文件既是程序又是是模块,但是程序和模块的设计目的是不同的,程序的目的是 ...
- elementUI实现日期框选中项文本高亮
{ margin: 0; font: 12px "Helvetica Neue" } p.p2 { margin: 0; font: 12px "PingFang SC& ...
- 多线程之volative关键字
目录 轻量级同步机制:volative关键字 volative的作用 volatile非原子特性 volatile与synchronized比较 常用原子类进行自增自减操作 CAS 使用CAS原理实现 ...
- ch1_6_5求解旋转词问题
import java.util.Scanner; public class ch1_6_5求解旋转词问题 { public static void main(String[] args) { // ...