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:

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

 #include<iostream>
#include<string>
#include<vector> using namespace std; bool judge(string& str)
{
bool flag = false; for(int i=;i<str.size();++i)
{
switch(str[i])
{
case '': str[i] = '@';flag = true;break;
case '': str[i] = '%';flag = true;break;
case 'l': str[i] = 'L';flag = true;break;
case 'O': str[i] = 'o';flag = true;break;
}
} return flag;
} int main()
{
int N;
string str1,str2;
vector<string> v; cin>>N; for(int i=;i<N;++i)
{
cin>>str1>>str2; if(judge(str2))
{
v.push_back(str1);
v.push_back(str2);
}
} if(v.size() == && N == )
cout<<"There is 1 account and no account is modified"<<endl;
else if(v.size() == && N > )
cout<<"There are " << N <<" accounts and no account is modified"<<endl;
else
{
cout<<v.size()/<<endl; for(int i=;i<v.size();i+=)
cout<<v[i]<<" "<<v[i+]<<endl;
}
}

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. div不固定高度垂直居中

    父容器的css属性 display:table;overflow:hidden;子容器的css属性 vertical-align:middle;display:table-cell; <!DOC ...

  2. 运维rpm语法

    Linux软件包分类 rpm 常用命令1.安装一个包 # rpm -ivh 2.升级一个包 # rpm -Uvh 3.卸载一个包 # rpm -e 4.安装参数 --force 即使覆盖属于其它包的文 ...

  3. 编辑器测试-TinyMCE

    一级标签 二级便签 引用段落1231456456 普通段落 链接 简书 https://www.jianshu.com/p/edee77363855 import pygame WINWIDTH = ...

  4. springboot application.properties 常用完整版配置信息

    从springboot官方文档中扒出来的,留存一下以后应该会用到 # ================================================================= ...

  5. 清理maven本地库中的lastUpdated文件

    通过CMD命令窗口进入响应的文件夹下 输入指令 for /r %i in (*.lastUpdated) do del %i

  6. break 和 continue 语句, 以及循环中的 else 子句

    break 语句工作得如同 C 语言一样, 跳出最小的 for 或 while 循环.循环语句可以有一个 else 子句; 该子句会在以下情况被执行: 循环因迭代到列表末尾而终止 (for 语句), ...

  7. PYTHON3-LIST.SORT(),SORTED()方法详解。

    python3对于排序提供两种内置方法,一是针对数组的list.sort(), 一是针对所有可迭代序列的sorted().其中list.sort()是在原数组修改,不产生新对象,所以在使用函数后使用赋 ...

  8. Codeforces Round #350 (Div. 2) C. Cinema

    Moscow is hosting a major international conference, which is attended by n scientists from different ...

  9. CentOS 7安全加固

    本次实验使用的centos 7 版本 一.查找系统中是否存在空密码账户 1.使用命令: awk -F: '($2==""){print $1}' /etc/shadow 直接查看. ...

  10. ROS * 了解xacro的编写

    在urdf文件中,会有很多内容是一样的,当要改变这些语句重某一个相同的参数时却要更改很多次,很吗发,于是有了一种精简化.可复用.模块化的描述形式——xacro 废话少说 声明重复使用的常量 <? ...