pat 1035 Password(20 分)
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 分)的更多相关文章
- PAT 甲级 1035 Password (20 分)(简单题)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for ...
- PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642
PAT (Advanced Level) Practice 1035 Password (20 分) 凌宸1642 题目描述: To prepare for PAT, the judge someti ...
- PAT甲级——1035 Password (20分)
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...
- PAT Advanced 1035 Password (20 分)
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...
- PAT (Advanced Level) Practice 1035 Password (20 分)
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...
- 【PAT甲级】1035 Password (20 分)
题意: 输入一个正整数N(<=1000),接着输入N行数据,每行包括一个ID和一个密码,长度不超过10的字符串,如果有歧义字符就将其修改.输出修改过多少组密码并按输入顺序输出ID和修改后的密码, ...
- 1035 Password (20分)(水)
To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem ...
- PAT 1035 Password
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for ...
- PAT 1035 Password [字符串][简单]
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...
随机推荐
- 如何巧妙地在基于 TCP Socket 的应用中实现用户注册功能?
通常,在基于TCP的应用中(比如我开源的GGTalk即时通信系统),当TCP连接建立之后,第一个请求就是登录请求,只有登录成功以后,服务器才会允许客户端进行其它性质的业务请求.但是,注册用户这个功能比 ...
- LWIP移植文件介绍
在介绍文件之前首先介绍一下DMA描述符 stm32以太网模块接收/发送FIFO和内存之间的以太网传输是通过以太网DMA使用DMA描述符完成的,一共有两个描述符列表:一个用于接收,一个用于发送, 两个列 ...
- php分页的条件
我们在项目开发的过程中避免不了使用分页功能,拿php来说,现在市面上有很多大大小小的php框架,当然了分页这种小功能这些框架中都是拿来直接可以用的. 这些框架的分页功能使用都很方便,配置一下分页所需参 ...
- Apache Pig中文教程集合
Apache Pig中文教程集合: http://www.codelast.com/?p=4550#more-4550
- 玩转PubSubClient MQTT库
1.前言 在ESP8266学习系列中,博主一直使用HTTP协议.HTTP连接属于短连接,而在物联网应用中,广泛应用的却是MQTT协议.所以,本篇我们将学习Arduino平台上的MQTT实现库 ...
- 百万年薪python之路 -- 并发编程之 多线程 一
多线程 1.进程: 生产者消费者模型 一种编程思想,模型,设计模式,理论等等,都是交给你一种编程的方法,以后遇到类似的情况,套用即可 生产者与消费者模型的三要素: 生产者:产生数据的 消费者:接收数据 ...
- MYSQL DATE_FORMAT参数列表及用法
MYSQL DATE_FORMAT参数列表及用法 主要涉及用法 DATE_SUB(DATE, INTERVAL EXPR TYPE) DATE_FORMAT(DATE,FORMAT) REPLACE( ...
- numpy+pandas+ matplotlib模块(day18)
目录 numpy模块 二维数组 numpy数组的属性 T 数组的装置 dtype 数组元素的数据类型 size 数组元素的个数 ndim 数组的维数 shape数组的维度大小 astype 类型转换 ...
- int和string的相互装换 (c++)
int和string的相互装换 (c++) int转换为string 第一种方法 to_string函数,这是c++11新增的函数 string to_string (int val); string ...
- Spring Cloud Eureka源码分析---服务注册
本篇我们着重分析Eureka服务端的逻辑实现,主要涉及到服务的注册流程分析. 在Eureka的服务治理中,会涉及到下面一些概念: 服务注册:Eureka Client会通过发送REST请求的方式向Eu ...