浙大pat 1035题解
1035. Password (20)
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题解的更多相关文章
- 浙大pat 1025题解
1025. PAT Ranking (25) 时间限制 200 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Programmi ...
- 浙大pat 1011题解
With the 2010 FIFA World Cup running, football fans the world over were becoming increasingly excite ...
- 浙大PAT 7-06 题解
#include <stdio.h> #include <iostream> #include <algorithm> #include <math.h> ...
- 浙大pat 1012题解
1012. The Best Rank (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue To eval ...
- 浙大 pat 1003 题解
1003. Emergency (25) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue As an emerg ...
- 浙大 pat 1038 题解
1038. Recover the Smallest Number (30) 时间限制 400 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...
- 浙大 pat 1047题解
1047. Student List for Course (25) 时间限制 400 ms 内存限制 64000 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Y ...
- 浙大pat 1054 题解
1054. The Dominant Color (20) 时间限制 100 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard Behind the scen ...
- 浙大pat 1059 题解
1059. Prime Factors (25) 时间限制 50 ms 内存限制 32000 kB 代码长度限制 16000 B 判题程序 Standard 作者 HE, Qinming Given ...
随机推荐
- trove manual installation 翻译
目标 此文件提供了一步一步的指导手动安装trove在一个现有OpenStack的环境为了开发. 该文件将不包括: OpenStack的设置 trove服务配置 要求 正在运行的OpenStack的环境 ...
- Python学习笔记进阶篇——总览
Python学习笔记——进阶篇[第八周]———进程.线程.协程篇(Socket编程进阶&多线程.多进程) Python学习笔记——进阶篇[第八周]———进程.线程.协程篇(异常处理) Pyth ...
- Linux学习-文件和目录管理
Linux文件和目录管理 文件系统架构 1.Linux文件系统具有层级性 1)文件或者目录起始于根目录"/"成为树状结构 2)最顶层由/开始 2 ...
- js分页模板
/** *参数说明: *currentPage:当前页数 *countPage:总页数 *changeMethod:执行java后台代码的js函数,即是改变分页数据的js函数 */ function ...
- 最全js 放大镜效果
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- weak引用变量是否线程安全
1.在ARC出现之前,Objetive-C的内存管理需要手工执行release&retain操作,这些极大增加了代码的编写难度,同时带来很多的crash. 同时大量的delegate是unr ...
- [Python]-类型转换
1.字符串到数值的转换:int(s [,base ]) 将表达式s转换为一个整数 ,s可以是整数,与数字有关的字符串,布尔类型long(s [,base ]) 将表达式s转换为一个长整数 s可以是整数 ...
- could not resolve property问题(ssh框架)
could not resolve property不能解析属性问题, 刚开始把hql语句中的"from User user where user.user_name = '"+u ...
- Tomcat多域名的配置
有时候我们有好几个项目需要发布在同一个tomcat服务器上,每个项目有不同的域名.这就需要在tomcat里配置多域名,添加多个虚拟主机. 主要在server.xml里面设置: 在<Engine& ...
- sealed的作用
sealed 修饰符表示密封 用于类时,表示该类不能再被继承,不能和 abstract 同时使用,因为这两个修饰符在含义上互相排斥 用于方法和属性时,表示该方法或属性不能再被重写,必须和 overri ...