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 replace1 (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 <cstdio>
#include <cstring>
#include <map>
#include <stack>
#include <vector>
#include <queue>
#include <set>
#define LL long long
using namespace std;
const int MAX = , MAXN = 1e3 + ; struct node
{
char s1[MAX], s2[MAX];
}P[MAXN];
char buf1[MAX], buf2[MAX];
int n, cnt = ;
map <char, char> mp; bool is_ans()
{
bool flag = false;
int len = strlen(buf2);
for (int i = ; i < len; ++ i)
{
if (mp.find(buf2[i]) != mp.end())
{
buf2[i] = mp[buf2[i]];
flag = true;
}
}
if (flag) return true;
return false;
} int main()
{
// freopen("Date1.txt", "r", stdin);
mp['l'] = 'L', mp['O'] = 'o', mp[''] = '@', mp[''] = '%';
scanf("%d", &n);
for (int i = ; i <= n; ++ i)
{
scanf("%s %s", &buf1, &buf2);
if (is_ans())
{
strcpy(P[cnt].s1, buf1);
strcpy(P[cnt ++].s2, buf2);
}
}
if (cnt != )
{
printf("%d\n", cnt);
for (int i = ; i < cnt; ++ i)
printf("%s %s\n", P[i].s1, P[i].s2);
return ;
}
if (n == )
printf("There is 1 account and no account is modified\n");
else
printf("There are %d accounts and no account is modified\n", n);
return ;
}

pat 1035 Password(20 分)的更多相关文章

  1. PAT 甲级 1035 Password (20 分)(简单题)

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

  2. PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642

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

  3. PAT甲级——1035 Password (20分)

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

  4. PAT Advanced 1035 Password (20 分)

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

  5. PAT (Advanced Level) Practice 1035 Password (20 分)

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

  6. 【PAT甲级】1035 Password (20 分)

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

  7. 1035 Password (20分)(水)

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

  8. PAT 1035 Password

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

  9. PAT 1035 Password [字符串][简单]

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

随机推荐

  1. vi/vim编辑器使用方法详解

    vi编辑器是所有Unix及Linux系统下标准的编辑器,他就相当于windows系统中的记事本一样,它的强大不逊色于任何最新的文本编辑器.他是我们使用Linux系统不能缺少的工具.由于对Unix及li ...

  2. Eureka错误解决方法

    # Eureka错误解决方法 ## security.basic.enabled 配置过时或不可用默认情况下:用户名:user密码:启动应用在控制台会输出,如下图: 也可以通过如下属性配置:sprin ...

  3. Centos7.4环境下搭建Python开发环境(虚拟机安装+python安装+pycharm安装)

    目录 一.安装 Centos7.4虚拟机 二.安装 python3.6.7 三.安装 pycharm 一般情况下,大家都是在 Windows平台下进行 Python开发,软件安装和环境搭建都非常&qu ...

  4. VSCode 安装 code 命令

    VSCode 提供 code 命令直接从命令行中打开文件目录,此时需要先安装 code 命令. 1.首先打开 VSCode 2.使用 command + shift + p (注意window 下使用 ...

  5. UNCTF杂项题Hidden secret 之NTFS交换数据流隐写

    ---恢复内容开始--- 做这道题目的经历比较坎坷,题目中用于隐藏flag的jpg文件出了问题,导致不能被交换数据流隐写所以出题人换了一次题目,最后做法也换了,不过出题人一开始的考察点还是基于NTFS ...

  6. codeforce -14A A. Letter

    A. Letter time limit per test 1 second memory limit per test 64 megabytes input standard input outpu ...

  7. 基于TORCS和Torch7实现端到端连续动作自动驾驶深度强化学习模型(A3C)的训练

    基于TORCS(C++)和Torch7(lua)实现自动驾驶端到端深度强化学习模型(A3C-连续动作)的训练 先占坑,后续内容有空慢慢往里填 训练系统框架 先占坑,后续内容有空慢慢往里填 训练系统核心 ...

  8. 第三篇 Flask中的request

    每个框架中都有处理请求的机制(request),但是每个框架的处理方式和机制是不同的,下面我们来了解一下Flask的request中都有什么东西 from flask import request 1 ...

  9. 2019-2020-1 20199314 《Linux内核原理与分析》 第八周作业

    可执行程序工作原理. 1.ELF(Executable and Linkable Format)可执行和可链接文件,其包含了以下三类: 可重定位文件(Relocatable File):保存着代码和适 ...

  10. spring boot跨域请求访问配置以及spring security中配置失效的原理解析

    一.同源策略 同源策略[same origin policy]是浏览器的一个安全功能,不同源的客户端脚本在没有明确授权的情况下,不能读写对方资源. 同源策略是浏览器安全的基石. 什么是源 源[orig ...