1035 Password (20)(20 point(s))
problem
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
tip
简单字符串处理
answer
#include<iostream>
#include<vector>
using namespace std;
int N;
vector<string > v;
bool Replace(string &s){
bool flag = false;
for(int j = 0; j < s.size(); j++){
// if(t[i] == '1') {
// t[i] = '@';
// flag = true;
// }
// if(t[i] == '0'){
// t[i] = '%';
// flag = true;
// }
//
// if(t[i] == 'l'){
// t[i] = 'L';
// flag = true;
// }
// if(t[i] == 'O'){
// t[i] = 'o';
// flag = true;
// }
switch(s[j]) {
case '1' : s[j] = '@'; flag = true; break;
case '0' : s[j] = '%'; flag = true; break;
case 'l' : s[j] = 'L'; flag = true; break;
case 'O' : s[j] = 'o'; flag = true; break;
}
}
return flag;
}
int main(){
// freopen("test.txt", "r", stdin);
cin>>N;
for(int i = 0; i < N; i++){
string a, p;
cin>>a>>p;
if(Replace(p)) {
string aa = a + " " + p;
v.push_back(aa);
}
}
if(v.size()){
printf("%d\n", v.size());
for(int i = 0; i < v.size(); i++){
cout<<v[i]<<endl;
}
}else if(v.size() == 0) {
if(N == 1) cout<<"There is "<<N<<" account and no account is modified"<<endl;
else printf("There are %d accounts and no account is modified", N);
}
return 0;
}
experience
- 这种题目应该尽量复制粘贴题目中的信息,血的教训。
1035 Password (20)(20 point(s))的更多相关文章
- A1035 Password (20)(20 分)
A1035 Password (20)(20 分) To prepare for PAT, the judge sometimes has to generate random passwords f ...
- PAT 甲级 1011 World Cup Betting (20)(20 分)
1011 World Cup Betting (20)(20 分)提问 With the 2010 FIFA World Cup running, football fans the world ov ...
- PAT 甲级 1001 A+B Format (20)(20 分)
1001 A+B Format (20)(20 分) Calculate a + b and output the sum in standard format -- that is, the dig ...
- PAT 1049 数列的片段和(20)(代码+思路分析)
1049 数列的片段和(20)(20 分) 给定一个正数数列,我们可以从中截取任意的连续的几个数,称为片段.例如,给定数列{0.1, 0.2, 0.3, 0.4},我们有(0.1) (0.1, 0.2 ...
- PAT 1033 旧键盘打字(20)(20 分)
1033 旧键盘打字(20)(20 分) 旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现.现在给出应该输入的一段文字.以及坏掉的那些键,打出的结果文字会是怎样? 输入格式: 输入在2 ...
- 【PAT】1019 数字黑洞 (20)(20 分)
1019 数字黑洞 (20)(20 分) 给定任一个各位数字不完全相同的4位正整数,如果我们先把4个数字按非递增排序,再按非递减排序,然后用第1个数字减第2个数字,将得到一个新的数字.一直重复这样做, ...
- PAT 1054 求平均值 (20)(代码+思路+测试用例)
1054 求平均值 (20)(20 分) 本题的基本要求非常简单:给定N个实数,计算它们的平均值.但复杂的是有些输入数据可能是非法的.一个"合法"的输入是[-1000,1000]区 ...
- 【PAT】1018 锤子剪刀布 (20)(20 分)
1018 锤子剪刀布 (20)(20 分) 大家应该都会玩“锤子剪刀布”的游戏:两人同时给出手势,胜负规则如图所示: 现给出两人的交锋记录,请统计双方的胜.平.负次数,并且给出双方分别出什么手势的胜算 ...
- PAT 甲级 1011 World Cup Betting (20)(20 分)(水题,不用特别在乎精度)
1011 World Cup Betting (20)(20 分) With the 2010 FIFA World Cup running, football fans the world over ...
- PTA 1005 Spell It Right (20)(20 分)水题
1005 Spell It Right (20)(20 分) Given a non-negative integer N, your task is to compute the sum of al ...
随机推荐
- 【转】线程间操作无效: 从不是创建控件“textBox2” 的线程访问它。
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...
- HDU 1719 Friend 规律题
解题报告:规定数字1和数字2是Friend number,然后规定,若a和b是Friend number,那么a*b+a+b也是Friend number,输入一个数,让你判断这个数是否是Friend ...
- linux tar 解压出错
今天用tar -xzvf php-7.2.3.tar.gz 解压php的tar包时报错 [root@VM_72_37_centos ~]# tar -xzvf php-.tar.gz gzip: st ...
- Windows无法访问局域网内共享文件夹[0x800704cf,0x80070035]解决方案
Windows7系统突然无法访问访问其他windows机器的共享文件夹,出现0x800704cf或者0x80070035错误: 解决方案如下两张图,配置与下面两张图为准,即可解决: 1:window+ ...
- [转]程序进行性能分析工具gprof使用入门
性能分析工具 软件的性能是软件质量的重要考察点,不论是在线服务程序还是离线程序,甚至是终端应用,性能都是用户体验的关键.这里说的性能重大的范畴来讲包括了性能和稳定性两个方面,我们在做软件测试的时候也是 ...
- CSS 实现单边阴影
box-shadow: 0px -15px 10px -15px #111; 五个值分别为:x y blur spread color 将 spread 设置成 blur 的负值即可 这种只适用于 o ...
- 推荐一本springBoot学习书籍---深入浅出springBoot2.x
花了几周时间读完了这本书,确实是一本特别详细全面的书,而且不单单只是springBoot, 书中还介绍了许多工作中常用的技术与springBoot的整合使用,当然,也有一些小bug, 因为在代码实践过 ...
- 渗透测试的WINDOWS NTFS技巧集合
译者:zzzhhh 这篇文章是来自SEC Consult Vulnerability Lab的ReneFreingruber (@ReneFreingruber),分享了过去几年从各种博客文章中收集的 ...
- 18 A GIF decoder: an exercise in Go interfaces 一个GIF解码器:go语言接口训练
A GIF decoder: an exercise in Go interfaces 一个GIF解码器:go语言接口训练 25 May 2011 Introduction At the Googl ...
- tftp的安装
下载并且安装软件xinetd tftp tftpd sudo apt-get install xinetd tftp tftpd 在/etc/xinetd.d/下建立一个配置文件tftp sudo v ...