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. weak引用变量是否线程安全

    1.在ARC出现之前,Objetive-C的内存管理需要手工执行release&retain操作,这些极大增加了代码的编写难度,同时带来很多的crash.  同时大量的delegate是unr ...

  2. Hololens文件读写

    unity 内勾选 RemovableStorage 选项或 Package.appxmanifest 勾选 可移动存储 选项 uwp app IO操作用 StreamReader 会提示没有权限,如 ...

  3. jquery css hover

    <script type="text/javascript"> $(function () { $("#<%=btnSubmit.ClientID%&g ...

  4. #if和#ifdef区别

    #if  是要去判断, 跟值有关 #ifdef  只要定义了即可, 就会走下面的代码, 不管值是0还是1 所以一般都是用#ifdef DEBUG调试

  5. Spring Security(14)——权限鉴定基础

    目录 1.1     Spring Security的AOP Advice思想 1.2     AbstractSecurityInterceptor 1.2.1    ConfigAttribute ...

  6. CentOS python升级到3.5时yum报错

    File except KeyboardInterrupt, e: ^ SyntaxError: invalid syntax 解决步骤: #vi /usr/bin/yum 将#!/usr/bin/p ...

  7. [Q]升级/重新获取授权步骤

    若因需要升级或授权文件失效(重装系统或其他原因),在服务期内可通过下面的步骤操作. 注:168元版提供2年升级及售后支持,118元版的提供1升级及售后支持. 步骤如下: 1. 重新获取CAD批量打图精 ...

  8. jquery中get传输方法实现读取xml文件

    xml文件: <?xml version="1.0" encoding="gb2312"?> <china> <province ...

  9. 输入身份证号码自动读取生日与性别(delphi)

    一.格式介绍: [15位号码格式] 1.第l一6位数为行政区划代码; 2.第7-12位数为出生日期代码; 3.第13---15位数为分配顺序代码; (1).行政区划代码,是指公民第一次申领居民身份证时 ...

  10. ios 关于tableview小技巧

    第一个:cell中的分割线不顶头 首先在viewDidLoad方法加入以下代码: if ([self.tableView respondsToSelector:@selector(setSeparat ...