PAT 甲级 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 分)的更多相关文章
- PAT 甲级 1035 Password (20 分)(简单题)
		
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for ...
 - PAT甲级——1035 Password (20分)
		
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...
 - PAT Advanced 1035 Password (20 分)
		
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...
 - PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642
		
PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...
 - PAT 甲级 1077 Kuchiguse (20 分)(简单,找最大相同后缀)
		
1077 Kuchiguse (20 分) The Japanese language is notorious for its sentence ending particles. Person ...
 - PAT 甲级 1061 Dating (20 分)(位置也要相同,题目看不懂)
		
1061 Dating (20 分) Sherlock Holmes received a note with some strange strings: Let's date! 3485djDk ...
 - 【PAT甲级】1035 Password (20 分)
		
题意: 输入一个正整数N(<=1000),接着输入N行数据,每行包括一个ID和一个密码,长度不超过10的字符串,如果有歧义字符就将其修改.输出修改过多少组密码并按输入顺序输出ID和修改后的密码, ...
 - PAT (Advanced Level) Practice 1035 Password (20 分)
		
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...
 - 【PAT】1035. Password (20)
		
题目:http://pat.zju.edu.cn/contests/pat-a-practise/1035 分析:简单题.直接搜索,然后替换,不会超时,但是应该有更好的办法. 题目描述: To pre ...
 
随机推荐
- TP5 生成二维码
			
首先下载这个类:http://phpqrcode.sourceforge.net/ 把下载的文件放到vendor下面 public function getWchatQrcode($users_id= ...
 - 2018—自学Selenium+Python 笔记(一)
			
在开始学习前,先唠几句: 身为一个开发人员,为何想要转测试..很多人不解. 但我觉得这并没有什么不可,测试人员是质量的把控者: 要出一个让客户满意的产品,单纯靠开发自测,是不够的..相信其中缘由大家都 ...
 - 关于TCP和MQTT之间的转换(转载)
			
现在物联网流行的就是MQTT 其实MQTT就是在TCP的基础上建立了一套协议 可以看这个,本来我自己想用Wireshark监听一下,不过百度一搜索一大把,我就不测试了 https://blog.csd ...
 - 如何通过Chrome远程调试android设备上的Web网站
			
网上的帖子很多,但很多都是老版本的,试过了,根本不管用,花了一天时间,终于在本机试验通过了,特记录下来,以备用.有需要的朋友也可以参考.先上一张图,看看PC端chrome上调试的效果: 左边是手机的模 ...
 - python中sys模块之输入输出错误流
			
import sys sys.stdout.write("msg") # 控制台白色字体打印 普通输出流 sys.stderr.write("msg") # ...
 - git版本管理工具常用命令
			
git是分布式版本管理工具,一台电脑既可以是客户端,也可以是服务端.工作过程中可以断开网络.svn是集中式版本管理工具,一台服务器控制很多客户端,使用过程不能断网. git的优点有:适合分布式开发,强 ...
 - spring注解注入:<context:component-scan>详解
			
spring从2.5版本开始支持注解注入,注解注入可以省去很多的xml配置工作.由于注解是写入java代码中的,所以注解注入会失去一定的灵活性,我们要根据需要来选择是否启用注解注入. 我们首先看一个注 ...
 - [Java Web学习]junit.framework.AssertionFailedError: No tests found in {Class}
			
No tests found in com.XXXXX.XXX.inboundPrepService.bizLogic.prepDeterminationEngine.workers.Determin ...
 - ELK 起航
			
ELK与我 我在2017年8月份第一次听说ELK并搭建了一次,当时看到KIBANA页面超级炫酷非常激动.现在已经过去了四个月了,现在的情况不像刚开始哪有无知了.现在是要应用到实际的项目中.首先说一下整 ...
 - 学习笔记TF055:TensorFlow神经网络简单实现一元二次函数
			
TensorFlow运行方式.加载数据.定义超参数,构建网络,训练模型,评估模型.预测. 构造一个满足一元二次函数y=ax^2+b原始数据,构建最简单神经网络,包含输入层.隐藏层.输出层.Tensor ...