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. Ueditor文件上传问题

    我们在做一些网站是会遇到,要有上传文件一类的事情. 我发现百度的富文本编辑器带上传功能,但是没有办法给后台传递我们要的参数. 先在ueditor.all.js中找到, me.execCommand(' ...

  2. 目标检测中proposal的意义

    在目标检测中,从很早就有候选区域的说法,也是在2008年可能就有人使用这个方法,在2014年的卷积神经网络解决目标检测问题的文章中,这个候选框方法大放异彩,先前的目标检测方法主要集中在使用滑动窗口的方 ...

  3. Html5NodeJs安装less之千辛万苦CMD系列

    如题,这个东西很是费了一般脑筋 上一次讲了如何在浏览器端解析less文件,这次是在cmd中使用npm中的less模块来解析 详解如下 首下我们去下载一个NodeJs,   我下载的是4.44版本,一路 ...

  4. hdu1034

    #include<stdio.h>const int MAXN=1000;int a[MAXN];int main(){ int n; int i; while(scanf("% ...

  5. hdu1029

    #include<iostream>#include<string.h>using namespace std;int main(){ int n,i; int t; int ...

  6. SEO之关键词选择

    在网站优化中,关键词应该是奠基石,选择好关键词的重要性也不言而喻了.怎样选择合理化的关键词呢?这个是我今天了解到的. 1.选择的关键词首先是有人搜索过的.没人搜索的词优化就是浪费时间. 2.做有效流量 ...

  7. wpf 遍历listview 时 传入指定类型 得到指定类型控件info

    private ChildType FindVisualChild<ChildType>(DependencyObject obj) where ChildType : Dependenc ...

  8. Math.round(),Math.ceil(),Math.floor()的区别

    1.Math.round():根据"round"的字面意思"附近.周围",可以猜测该函数是求一个附近的整数,看下面几个例子就明白. 小数点后第一位<5 正 ...

  9. 【Python之路】第九篇--Python基础之线程、进程和协程

    进程与线程之间的关系 线程是属于进程的,线程运行在进程空间内,同一进程所产生的线程共享同一内存空间,当进程退出时该进程所产生的线程都会被强制退出并清除.线程可与属于同一进程的其它线程共享进程所拥有的全 ...

  10. mycat 概述

    从开始接触mycat,到现在为止也有三个多月的时间了,目前在测试环境中已经初步应用!大概可以总结一下了 mycat是一个数据库中间件,也可以理解为是数据库代理.在架构体系中是位于数据库和应用层之间的一 ...