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. windows 身份登录(vs设置)

    如果您的项目是windows身份严重,前提是我们用域账户登录,不用单独做登录页功能了. 一.如果用IE访问方法: 进入:工具-Internet选项-安全-自定义级别,如下设置即可. 二.如果用Visu ...

  2. 2016.07.15——istringstream测试

    istringstream测试 1.istringstream strcin(str),字符串(str)可以包括多个单词,单词之间使用空格分开 #include "stdafx.h" ...

  3. win10安装

    1.启动盘制作 首先我们需要登陆“微软中国下载中心”,从中下载一款名为“MediaCreationTool”的工具,利用该工具可以制作Win10安装U盘.直接通过以下地址快速进入“Windows下载中 ...

  4. 【算法】Base64编码

    1.说明 Base64是网络上最常见的用于传输8Bit字节码的编码方式之一,Base64就是一种基于64个可打印字符来表示二进制数据的方法. 2.编码 ASCII码 -> 十六进制码 -> ...

  5. python几种装饰器的用法

    用函数装饰函数 这种比较常见首先定义装饰器函数 def cache(func): data = {} @wraps(func) def wrapper(*args, **kwargs): key = ...

  6. C# 链接webservice报错

    未处理 System.ServiceModel.EndpointNotFoundException  Message="没有终结点对可能接受消息的 http://192.168.0.168/ ...

  7. [转]在C#程序设计中使用Win32类库

    http://blog.163.com/j_yd168/blog/static/496797282008611326218/     C# 用户经常提出两个问题:“我为什么要另外编写代码来使用内置于 ...

  8. asp.net mvc发送邮件

    参考文献: 第一篇:http://www.cnblogs.com/qinpengming/archive/2011/06/08/2075040.html 第二篇:http://www.cnblogs. ...

  9. sqlserver中一些常用的函数总结

    去掉空格方面 LTRIM('内容'):去掉字符串左边的空格 RTRIM('内容'):去掉右边的空格 LTRIM(RTRIM('内容')):去掉字符串左边和右边的空格 REPLACE(‘内容’,' ', ...

  10. python网络编程-动态导入和断言

    一:动态导入importlib 在程序运行的过程中,根据变量或者配置动态的决定导入哪个模块,可以使用模块importlib importlib使用示例 二:断言assert 如果接下来的程序依赖于前面 ...