1035 Password (20 分)

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:

  1. 3
  2. Team000002 Rlsp0dfa
  3. Team000003 perfectpwd
  4. Team000001 R1spOdfa

Sample Output 1:

  1. 2
  2. Team000002 RLsp%dfa
  3. Team000001 R@spodfa

Sample Input 2:

  1. 1
  2. team110 abcdefg332

Sample Output 2:

  1. There is 1 account and no account is modified

Sample Input 3:

  1. 2
  2. team110 abcdefg222
  3. team220 abcdefg333

Sample Output 3:

  1. There are 2 accounts and no account is modified
  2.  
  1. #include<iostream>
  2. #include<string>
  3. #include<vector>
  4.  
  5. using namespace std;
  6.  
  7. bool judge(string& str)
  8. {
  9. bool flag = false;
  10.  
  11. for(int i=;i<str.size();++i)
  12. {
  13. switch(str[i])
  14. {
  15. case '': str[i] = '@';flag = true;break;
  16. case '': str[i] = '%';flag = true;break;
  17. case 'l': str[i] = 'L';flag = true;break;
  18. case 'O': str[i] = 'o';flag = true;break;
  19. }
  20. }
  21.  
  22. return flag;
  23. }
  24.  
  25. int main()
  26. {
  27. int N;
  28. string str1,str2;
  29. vector<string> v;
  30.  
  31. cin>>N;
  32.  
  33. for(int i=;i<N;++i)
  34. {
  35. cin>>str1>>str2;
  36.  
  37. if(judge(str2))
  38. {
  39. v.push_back(str1);
  40. v.push_back(str2);
  41. }
  42. }
  43.  
  44. if(v.size() == && N == )
  45. cout<<"There is 1 account and no account is modified"<<endl;
  46. else if(v.size() == && N > )
  47. cout<<"There are " << N <<" accounts and no account is modified"<<endl;
  48. else
  49. {
  50. cout<<v.size()/<<endl;
  51.  
  52. for(int i=;i<v.size();i+=)
  53. cout<<v[i]<<" "<<v[i+]<<endl;
  54. }
  55. }

PAT 甲级 1035 Password (20 分)的更多相关文章

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

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

  2. PAT甲级——1035 Password (20分)

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

  3. PAT Advanced 1035 Password (20 分)

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

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

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

  5. PAT 甲级 1077 Kuchiguse (20 分)(简单,找最大相同后缀)

    1077 Kuchiguse (20 分)   The Japanese language is notorious for its sentence ending particles. Person ...

  6. PAT 甲级 1061 Dating (20 分)(位置也要相同,题目看不懂)

    1061 Dating (20 分)   Sherlock Holmes received a note with some strange strings: Let's date! 3485djDk ...

  7. 【PAT甲级】1035 Password (20 分)

    题意: 输入一个正整数N(<=1000),接着输入N行数据,每行包括一个ID和一个密码,长度不超过10的字符串,如果有歧义字符就将其修改.输出修改过多少组密码并按输入顺序输出ID和修改后的密码, ...

  8. PAT (Advanced Level) Practice 1035 Password (20 分)

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

  9. 【PAT】1035. Password (20)

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

随机推荐

  1. WebStorm 破解方法

    WebStorm 破解方法 第一步 打开 IntelliJ IDEA 注册码 网址,点击下载最新的 破解补丁 第二步 将下载下来的破解补丁,复制到WebStorm 安装目录的bin目录下 第三步 修改 ...

  2. Ubuntu + Nginx 配置全站https访问

    最近跟室友要一起搞一个个人公众号,提前想把生态想清楚了,所以准备部署一个网站 正好公司有Microsoft Visual Studio Professional订阅,每个月有50刀免费额度,对于Azu ...

  3. 学习java一个月的进展

    作为一个阶段性总结,有很多的东西需要说明,有细节的,有架构的,且听我细细说来. java和php最大的区别不止是类型的强制定义,而是在设计思路上有着非常重大的偏差(虽然SY3框架已经开始借鉴JAVA的 ...

  4. sys os

     python常用的一些东西——sys.os等(转) 2012-09-19 14:51:4 1.常用内置函数:(不用import就可以直接使用)      help(obj) 在线帮助, obj可是任 ...

  5. qt 利用 HTML 生成PDF文档,不能显示jpg图片

    利用 QPrinter 和html 生成 pdf文档 其中用html语句有显示图片的语句 但只能显示png格式的图片,不能显示jpg格式图片. 经过排查:语法,文件路径等都正确,最终在stack ov ...

  6. mysql 导入数据库问题

    今天数据库迁移测试,发现存储过程导入不了,提示如下错误: Cannot load from mysql.proc. The table is probably corrupted 原因是mysql5. ...

  7. 使用min-device-pixel-ratio媒体功能实现真正的1像素border

    关于设备像素比的知识,想必做过移动端开发的都有接触,这里就不介绍啦,万一有不懂的可以看张鑫旭大神的设备像素比devicePixelRatio简单介绍 由于设备像素比存在的原因,我们在处理设计图的一些边 ...

  8. 在typeScript+vue项目中使用ref

    因为vue项目是无法直接操作dom的,但是有时候开发需求迫使我们去操作dom. 两个办法,一个是很low的再引入jq,然后通过jq来操作,但是这样就失去了我们使用vue的意义, 可惜的是我曾经这样干过 ...

  9. Filter用户例子

    用Filter防止用户访问一些未被授权的资源,比如一个用户未登录就不允许访问网站的某些页面,并将页面重定向到需要用户登录的页面,下面是一个相关的例子: package com.drp.util.fil ...

  10. 关于crontab

    crontab是一个linux系统自带的定时执行任务的功能,有两种方法可以实现 1: 使用命令 crontab -e 然后直接编辑定时脚本,实际是编辑/var/spool/cron 目录下,一个和用户 ...