1035. Password (20)

时间限制
400 ms

内存限制
65536 kB

代码长度限制
16000 B

判题程序
Standard

作者
CHEN, Yue

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 (<= 1000), 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


提交代码

 1 #include<cstdio>
 2 #include<stack>
 3 #include<algorithm>
 4 #include<iostream>
 5 #include<stack>
 6 #include<set>
 7 #include<map>
 8 #include<vector>
 9 using namespace std;
10 vector<string> v;
11 map<string,string> ha;
12 bool check(char &c){
13     if(c=='1'){
14         c='@';
15         return true;
16     }
17     if(c=='0'){
18         c='%';
19         return true;
20     }
21     if(c=='l'){
22         c='L';
23         return true;
24     }
25     if(c=='O'){
26         c='o';
27         return true;
28     }
29     return false;
30 }
31 int main(){
32     //freopen("D:\\INPUT.txt","r",stdin);
33     int n;
34     scanf("%d",&n);
35     int i,j;
36     string num,pas;
37     int count=0;
38     for(i=0;i<n;i++){
39         cin>>num>>pas;
40         bool can=false;
41         for(j=0;j<pas.length();j++){
42             if(check(pas[j])){
43                 can=true;
44             }
45         }
46         if(can){
47             count++;
48             v.push_back(num);
49             ha[num]=pas;
50         }
51     }
52     if(count){
53         printf("%d\n",count);
54         for(j=0;j<v.size();j++){
55             cout<<v[j]<<" "<<ha[v[j]]<<endl;
56         }
57     }
58     else{
59         if(n==1){
60             printf("There is 1 account and no account is modified\n",n);
61         }
62         else{
63             printf("There are %d accounts and no account is modified\n",n);
64         }
65     }
66     return 0;
67 }

转载于:https://www.cnblogs.com/Deribs4/p/4782220.html

pat1035. Password (20)相关推荐

  1. 1035 Password (20 分)

    1035 Password (20 分) 题目大意 给定n个用户的姓名和密码,把密码中的1改为@,0改为%,l改为L,O改为o 如果不存在需要修改的密码,则输出There are n accounts ...

  2. 【测试点分析】1035 Password (20 分)

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 To prepare for PAT, the judge sometimes has to generate random pa ...

  3. 【PAT甲级 替换指定字符】1035 Password (20 分) Java版 4/4通过

    题目 这个题挺简单,意思就是把所有的1替换成@,0替换成%等等 读题要仔细,输出格式方面有几个小坑: 末尾不要有多余的空格.换行 如果替换了,要在第一行输出替换的条数 如果没替换,要把题目给的字符串拼 ...

  4. PAT (Advanced Level) 1035. Password (20)

    简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...

  5. PAT甲级1035 Password

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

  6. table中加表单元素怎么验证_element-ui 解决 table 里包含表单验证的问题!

    实际项目中的场景,需要在table里做表单的验证,如图效果: 其实问题关键就在于如何给el-form-item动态绑定prop :prop="'tableData.' + scope.$in ...

  7. 使用 Struts2 校验器校验用户注册信息的例子

    转自:https://blog.csdn.net/jin2005006/article/details/53999562 基于验证框架的输入校验 一.创建一个struts2项目testValidato ...

  8. Python基础04-数据类型:数字、布尔、字符串

    目录 数字 布尔 字符串 字符串的常用函数 字符串的内存分析 字符串练习题 数字 判断是数字类型还是字符串类型. # <class 'str'> 123 a = "123&quo ...

  9. oracle 插入 基准测试,oracle proc 插入操作性能优化实践

    场景: student 表中 10万条数据. 从 student 表中取出所有数据,插入到 student_his 表中 优化方法: 1.批量插入(效果明显) 2.批量查询(效果不明显) 3.批量提交 ...

最新文章

  1. istio安装命令整理
  2. 相对湿度计算软件_冷却塔填料的用量要怎么计算?
  3. 双十一,单身狗除了买买买,还能做什么?
  4. CF1572B. Xor of 3
  5. Shallow Copy Deep Copy in Python list
  6. mysql gender_Mysql第一弹
  7. antd 判断input输入内容是否大于_Python基础语法 | 代码规范amp;判断语句amp;循环语句...
  8. Python预测2020高考分数和录取情况
  9. 深入了解C++变量类型有哪些
  10. ArcGIS Server .net Web ADF 体系结构
  11. 一文看懂STM32单片机和51单片机区别
  12. 群晖NPV套件(NPV Server)官方下载方法
  13. Mac电脑没声音的解决方法
  14. 乌云沙龙:赛棍的自我修养
  15. 饿了么口碑发布“暖冬计划”PK美团,降低费率让利商家
  16. java jws配置_与WordNet有关的两个JAVA库(JWNL和JWS)的配置
  17. java excel进度条_导出excel 用easyui显示进度条(也适用于其他框架遮罩层,进度条)...
  18. 3dmax安装后破解Couldn't write to disk !
  19. java sign函数_C / C ++中是否有标准的符号函数(signum,sgn)?
  20. Spark入门之九:机器学习简介

热门文章

  1. cp命令复制目录 不覆盖
  2. muduo学习笔记 线程类
  3. mysql b tree图_MySQL索引--B-Tree(B+Tree)图文详解
  4. java信用分秒杀系统设计思路,秒杀系统设计思路
  5. 201712-2放学
  6. python-语言播报
  7. 412. Fizz Buzz
  8. Objective -C Memory Management 内存管理 第一部分
  9. Lucene排序以及自定义排序
  10. SharePoint 2007 URL地址快速一览表