PAT 甲级 1035 Password (20 分)

时间:2022-10-08 14:15:14
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<string>
#include<vector> using namespace std; bool judge(string& str)
{
bool flag = false; for(int i=;i<str.size();++i)
{
switch(str[i])
{
case '': str[i] = '@';flag = true;break;
case '': str[i] = '%';flag = true;break;
case 'l': str[i] = 'L';flag = true;break;
case 'O': str[i] = 'o';flag = true;break;
}
} return flag;
} int main()
{
int N;
string str1,str2;
vector<string> v; cin>>N; for(int i=;i<N;++i)
{
cin>>str1>>str2; if(judge(str2))
{
v.push_back(str1);
v.push_back(str2);
}
} if(v.size() == && N == )
cout<<"There is 1 account and no account is modified"<<endl;
else if(v.size() == && N > )
cout<<"There are " << N <<" accounts and no account is modified"<<endl;
else
{
cout<<v.size()/<<endl; for(int i=;i<v.size();i+=)
cout<<v[i]<<" "<<v[i+]<<endl;
}
}

PAT 甲级 1035 Password (20 分)的更多相关文章

  1. PAT 甲级 1035 Password &lpar;20 分&rpar;(简单题)

    1035 Password (20 分)   To prepare for PAT, the judge sometimes has to generate random passwords for ...

  2. PAT甲级——1035 Password &lpar;20分&rpar;

    To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...

  3. PAT Advanced 1035 Password &lpar;20 分&rpar;

    To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...

  4. PAT &lpar;Advanced Level&rpar; Practice 1035 Password &lpar;20 分&rpar; 凌宸1642

    PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...

  5. PAT 甲级 1077 Kuchiguse &lpar;20 分&rpar;(简单,找最大相同后缀)

    1077 Kuchiguse (20 分)   The Japanese language is notorious for its sentence ending particles. Person ...

  6. PAT 甲级 1061 Dating &lpar;20 分&rpar;(位置也要相同,题目看不懂)

    1061 Dating (20 分)   Sherlock Holmes received a note with some strange strings: Let's date! 3485djDk ...

  7. 【PAT甲级】1035 Password &lpar;20 分&rpar;

    题意: 输入一个正整数N(<=1000),接着输入N行数据,每行包括一个ID和一个密码,长度不超过10的字符串,如果有歧义字符就将其修改.输出修改过多少组密码并按输入顺序输出ID和修改后的密码, ...

  8. PAT &lpar;Advanced Level&rpar; Practice 1035 Password &lpar;20 分&rpar;

    To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...

  9. 【PAT】1035&period; Password &lpar;20&rpar;

    题目:http://pat.zju.edu.cn/contests/pat-a-practise/1035 分析:简单题.直接搜索,然后替换,不会超时,但是应该有更好的办法. 题目描述: To pre ...

随机推荐

  1. Scalaz&lpar;0&rpar; - 写在前面

    面向对象编程范畴(OOP)从80年代C++到90年代java的兴起已经经历了几十年的高潮,是不是已经发展到了尽头,该是函数式编程(FP)开始兴旺发达的时候了吧.这样说似乎心眼儿有点坏,可能会得罪当今大 ...

  2. linux环境下deb格式 转换成rpm格式

    linux环境下deb格式 转换成rpm格式 使用alien工具转换deb格式到rpm格式 alien_8.87.tar.gz 下载alien_8.87.tar.gz [root@mysqlnode2 ...

  3. sort&lpar;水题&rpar;

    sort Time Limit: 6000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  4. table可更改th大小的jQuery插件

    (function ($) { $.fn.resizetable = function () { var tableObj = $(this); var inResizeRange = false; ...

  5. 如何面试 PHP 工程师?

    1,解决问题的能力和掌握的知识,看你招聘的目的而决定其二者的平衡.了解流体力学的确会对通下水道有很大帮助,但流体力学专家未必都会疏通下水道. 2,创造力,一个没有自己作品的程序员不是好程序员.编程跟写 ...

  6. Java操作zookeeper

    Java操作zookeeper总共有三种方式: 1.原生的Java API 2.zkclient 3.curator 第一种实现代码: pom.xml <dependency> <g ...

  7. ~递归递归(FBI树--蓝桥)

    1220: FBI树 [递归] 时间限制: 1 Sec 内存限制: 128 MB 提交: 5 解决: 4 状态 题目描述 我们可以把由“0”和“1”组成的字符串分为三类:全“0”串称为B串,全“1”串 ...

  8. Storm入门到精通(四)---本地实例Demo

    单词实时计数 maven项目的结构: 一.Pom.xml [html] view plain copy <project xmlns="http://maven.apache.org/ ...

  9. Spring Boot1&period;5X升级到2&period;0

    配置文件 大量的Servlet专属的server.* properties被移到了server.servlet下 拦截器 public class MyWebMvcConfigurerAdapter ...

  10. Python沙盒环境配置

    一.简介 本文介绍配置python沙盒环境的方法步骤. 二.安装步骤 1.安装pyenv http://www.cnblogs.com/274914765qq/p/4948530.html 2.安装v ...