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))的更多相关文章

  1. A1035 Password (20)(20 分)

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

  2. 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 ...

  3. 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 ...

  4. PAT 1049 数列的片段和(20)(代码+思路分析)

    1049 数列的片段和(20)(20 分) 给定一个正数数列,我们可以从中截取任意的连续的几个数,称为片段.例如,给定数列{0.1, 0.2, 0.3, 0.4},我们有(0.1) (0.1, 0.2 ...

  5. PAT 1033 旧键盘打字(20)(20 分)

    1033 旧键盘打字(20)(20 分) 旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现.现在给出应该输入的一段文字.以及坏掉的那些键,打出的结果文字会是怎样? 输入格式: 输入在2 ...

  6. 【PAT】1019 数字黑洞 (20)(20 分)

    1019 数字黑洞 (20)(20 分) 给定任一个各位数字不完全相同的4位正整数,如果我们先把4个数字按非递增排序,再按非递减排序,然后用第1个数字减第2个数字,将得到一个新的数字.一直重复这样做, ...

  7. PAT 1054 求平均值 (20)(代码+思路+测试用例)

    1054 求平均值 (20)(20 分) 本题的基本要求非常简单:给定N个实数,计算它们的平均值.但复杂的是有些输入数据可能是非法的.一个"合法"的输入是[-1000,1000]区 ...

  8. 【PAT】1018 锤子剪刀布 (20)(20 分)

    1018 锤子剪刀布 (20)(20 分) 大家应该都会玩“锤子剪刀布”的游戏:两人同时给出手势,胜负规则如图所示: 现给出两人的交锋记录,请统计双方的胜.平.负次数,并且给出双方分别出什么手势的胜算 ...

  9. 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 ...

  10. 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 ...

随机推荐

  1. POJ 3468 A Simple Problem with Integers (区间更新+区间查询)

    题目链接 Description You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operation ...

  2. Jetson TX1 安装Kinect驱动

    1.添加Universe源 $ sudo apt-add-repository universe $ sudo apt-get update 2.安装编译工具和依赖项 $ sudo apt-get i ...

  3. Servlet笔记2--模拟Servlet本质、第一个Servlet程序、将响应结果输出到浏览器中

    以下代码均非IDE开发,所以都不规范,仅供参考 模拟Servlet本质: 模拟Servlet接口: /* SUN公司制定的JavaEE规范:Servlet规范 Servlet接口是Servlet规范中 ...

  4. connect系统调用

    /* * Attempt to connect to a socket with the server address. The address * is in user space so we ve ...

  5. Southwestern Europe Regional Contest 2015 题解

    题目链接:http://codeforces.com/gym/101128 题目数7/10 Rank 34/209 A: 题意:给出一张n个点的有向图表示一家有n个员工的公司的隶属图,u->v表 ...

  6. Python2和Python3同时安装到Windows

    上月已经把Python2安装好了,安装目录和及其下的Scripts也在安装时添加到了环境变量PATH中,可以使用python命令执行程序. 安装包:python-2.7.14.amd64.msi(没有 ...

  7. Python 文件IO

    Python 文件I/O 打印到屏幕 最简单的输出方法是用print语句,你可以给它传递零个或多个用逗号隔开的表达式.此函数把你传递的表达式转换成一个字符串表达式,并将结果写到标准输出如下: #!/u ...

  8. caffe+win7+vs2013 仅CPU环境安装

    笔者对深度学习一直充满着好奇与兴趣,之前学校都是研究图像处理的特征点方式,机器学习使用也不多,别提深度学习了. 在看了李宏毅大佬的PPT后,有了初步的认识,虽然是渣渣电脑,也想自己跑几个深度模型. 说 ...

  9. 洛谷P3760异或和

    传送门啦 传送门啦 一般这种位运算的题都要把每一位拆开来看,因为位运算每个位的结果这和这一位的数有关. 这样我们用s[i]表示a的前缀和,即 $ a[1]+a[2]+....a[i] $ ,然后我们从 ...

  10. wpf image blur

    RenderOptions.BitmapScalingMode="NearestNeighbor"