1035. Password (20)

时间限制
400 ms
内存限制
32000 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue

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 "algorithm"
#include "string"
#include "vector"
using namespace std;

struct PAT
{
string username;
string password;
};
int num =0;
bool FindWords(string &s)
{
bool temp = false;
int n = s.size();
int i;
for( i=0;i<n;i++)
{
if(s[i]=='1')
{
s[i]='@';
temp =true;
}
if(s[i]=='0')
{
s[i]='%';
temp =true;
}
if(s[i]=='l')
{
s[i]='L';
temp =true;
}
if(s[i]=='O')
{
s[i]='o';
temp =true;
}
}
return temp;

}
int main()
{
vector<PAT>p;
int n;
cin >> n;
PAT pat;
for(int i=0;i<n;i++)
{
cin >> pat.username >> pat.password;
if(FindWords(pat.password))
{
p.push_back(pat);
num++;
}
}
if(n==1&&num==0)
cout<<"There is 1 account and no account is modified"<<endl;
else if(num==0)
cout<<"There are "<<n<<" accounts and no account is modified"<<endl;
else if(num!=0)
{
cout << num<<endl;
vector<PAT>::iterator it = p.begin();
while(it!=p.end())
{
cout << (*it).username<<" "<<(*it).password<<endl;
it++;
}

}

return 0;
}

浙大pat 1035题解的更多相关文章

  1. 浙大pat 1025题解

    1025. PAT Ranking (25) 时间限制 200 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programmi ...

  2. 浙大pat 1011题解

    With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...

  3. 浙大PAT 7-06 题解

    #include <stdio.h> #include <iostream> #include <algorithm> #include <math.h> ...

  4. 浙大pat 1012题解

    1012. The Best Rank (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To eval ...

  5. 浙大 pat 1003 题解

    1003. Emergency (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue As an emerg ...

  6. 浙大 pat 1038 题解

    1038. Recover the Smallest Number (30) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...

  7. 浙大 pat 1047题解

    1047. Student List for Course (25) 时间限制 400 ms 内存限制 64000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Y ...

  8. 浙大pat 1054 题解

    1054. The Dominant Color (20) 时间限制 100 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard Behind the scen ...

  9. 浙大pat 1059 题解

    1059. Prime Factors (25) 时间限制 50 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 HE, Qinming Given ...

随机推荐

  1. iOS 加载Image的两种方式

    Apple官方文档对于加载image提供了两个方法 + (nullable UIImage *)imageNamed:(NSString *)name; + (nullable UIImage *)i ...

  2. 遇到个奇怪的问题,同时开启本地和远程两个事务,远程事务是sql2000没问题,是sql2008的不报错,但是写不上数据

    遇到个奇怪的问题,同时开启本地和远程两个事务,远程事务是sql2000没问题,是sql2008的不报错,但是写不上数据. 倒腾了4.5天,找到最终的解决办法:直接调用AdoConnection.exe ...

  3. 微信小程序前置课程:flex布局(二)

    原文:http://www.ruanyifeng.com/blog/2015/07/flex-examples.html 上一篇文章介绍了Flex布局的语法,今天介绍常见布局的Flex写法. 你会看到 ...

  4. 安卓---android:versionCode和android:versionName 用途

    主要用于升级和自我识别,转自:http://blog.csdn.net/wh_19910525/article/details/8660416 Android的版本可以在androidmainfest ...

  5. MATLAB中的多项式运算

    作者:长沙理工大学 交通运输工程学院 王航臣 1.多项式求根 在MATLAB中求取多项式的根用roots函数. 函数:roots 功能:一元高次方程求解. 语法:roots(c) 说明:返回一个列向量 ...

  6. UGUI事件系统

    UGUI系统 将UI可能触发的事件分为12个类型,即EventTriggerType枚举的12个值. PointerEnter-- PointerExit-- PointerDown-- Pointe ...

  7. 解决 spring mvc 3.+ 结合 hibernate3.+ 使用<tx:annotation-driven>声明式事务无法提交的问题

    spring mvc使用注解方式:service使用@service注解 事务使用@Transactional 事务配置使用 <tx:annotation-driven transaction- ...

  8. 算法系列——huffman编码

    哈夫曼编码,旨在对信息实现一种高效的编码,这种编码中任何一个都不是其他编码的前缀码.因此,在实际接收时,一旦匹配,就可以立即解码. 具体算法过程可以参加网上的很多教程. 给出一个自己的实现,一方面加强 ...

  9. js判断数组里面的值是否相等。

    var zhi=[]; var zhiT=[]; //var arr=["a","b","a","a"]; var ar ...

  10. Unity3DGUI:人物能量条