浙大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 ...
随机推荐
- InnoDB引擎数据存放位置
InnoDB引擎的mysql数据存放位置 采用InnoDB引擎的数据库创建表后,会在mysql数据存放目录下生成一个和数据库名相同的目录.该目录下包涵一个db.opt文件和该库下所有表同名的frm文件 ...
- IPython与notebook 安装
基于 python2.7.13 32-bit版本安装 1.安装pyreadline https://pypi.python.org/pypi/pyreadline 下载对应的32位版本 2.用pip安 ...
- 前端之Photoshop切片
什么是切片 ? (Photoshop中的切片) 切片:将图片切成几部分,一片一片往上传,这样上传的速度比较快.每个切片作为一个独立的文件传输,文件中包含切片自己的设置.颜色调板.链接.翻转效果 ...
- gulp 安装步骤
第一步:安装node 搭建node环境:进入官网 http://nodejs.org ,然后点击的绿色的 install 按钮,下载完成后直接运行程序. 第二步:使用命令行 (1)输入指令:node ...
- .net XML操作
一.常规介绍 //初始化一个xml对象 XmlDocument xml = new XmlDocument(); //加载xml文件 xml.Load("文件路径"); //读取指 ...
- ios开发之简单实现loading动画效果
最近有朋友问我类似微信语音播放的喇叭动画和界面图片加载loading界面是怎样实现的,是不是就是一个gif图片呢!我的回答当然是否定了,当然不排除也有人用gif图片啊!下面我就来罗列三种实现loadi ...
- openstack私有云布署实践【9.3 主从controller单向同步glance-image目录】
采用Rysnc单向同步,而不用双方实时同步,原因是在历史的运行过程中,我们发现,有些镜像包太大,当在主用的glance将镜像保存时,并不是一时半会就把镜像保存好,当主用在保存时,备用节点又在实时同步那 ...
- 相机标定 matlab opencv ROS三种方法标定步骤(1)
一 . 理解摄像机模型,网上有很多讲解的十分详细,在这里我只是记录我的整合出来的资料和我的部分理解 计算机视觉领域中常见的三个坐标系:图像坐标系,相机坐标系,世界坐标系,实际上就是要用矩阵来表 示各个 ...
- os库-时间函数
一.时间的三种格式 1.用数值表示时间值 (时间戳)用数字值来表示时间值,实际上时间值的本质就是一个数字值.例如:d = 1131286477 这里的 1131286477 是一个以秒为单位的 格林威 ...
- datagrid、easyui-dialog
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...