https://pintia.cn/problem-sets/994805342720868352/problems/994805454989803520

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 <bits/stdc++.h>
using namespace std; char username[20], pw[20];
char userr[1111][20], pww[1111][20];
char s1[5] = {'1', '0', 'l', 'O'};
char s2[5] = {'@', '%', 'L', 'o'}; int yes(char a[20]) {
int len = strlen(a);
bool flag = false;
for(int i = 0; i < len; i ++) {
for(int j = 0; j <= 3; j ++) {
if(a[i] == s1[j])
flag = true;
}
}
if(flag) return 1;
else return 0;
} int main() {
int n;
scanf("%d", &n);
int cnt = 0;
for(int i = 1; i <= n; i ++) {
scanf("%s%s", username, pw);
cnt += yes(pw);
if(yes(pw) == 1) {
strcpy(userr[cnt], username);
int lenn = strlen(pw);
for(int j = 0; j < lenn; j ++) {
for(int k = 0; k <= 3; k ++) {
if(pw[j] == s1[k])
pw[j] = s2[k];
}
}
strcpy(pww[cnt], pw);
}
} if(cnt == 0) {
if(n == 1)
printf("There is 1 account and no account is modified\n");
else
printf("There are %d accounts and no account is modified\n", n);
} else {
printf("%d\n", cnt);
for(int i = 1; i <= cnt; i ++)
printf("%s %s\n", userr[i], pww[i]);
} return 0;
}

  

PAT 甲级 1035 Password的更多相关文章

  1. PAT 甲级 1035 Password (20 分)

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

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

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

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

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

  4. 【PAT】1035. Password (20)

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

  5. PAT Advanced 1035 Password (20 分)

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

  6. PAT甲级——A1035 Password

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

  7. PAT 1035 Password

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

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

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

  9. pat 1035 Password(20 分)

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

随机推荐

  1. SQL基于时间的盲注过程

    0x00 前言 由于要使用到基于时间的盲注,但是我觉得基于时间的盲注其实就是基于布尔的盲注的升级版,所以我想顺便把基于布尔的盲注分析总结了: 首先我觉得基于时间的盲注和基于布尔的盲注的最直观的差别就是 ...

  2. C语言顺序队列

    顺序队列是一种只能在一头进和另一头出的数据结构,所以结构体里设2个指针分别指向头部和尾部,用数组来存储数据. #define MAXSIZE 1024 typedef int elemtype; ty ...

  3. C语言实现可复用栈

    一.思考 最开始写的栈,通过宏来改变元素数据类型,在同一程序中只能用于一种数据类型,想要用于多种数据类型则要复制代码并改名.那么,有没有方法不复制代码就可以用于多种数据类型? 二.基本思路 在我的经验 ...

  4. 利用“海底捞算法”在MongoDB中优雅地存储一棵树

    目前常见的树形结构数据库存储方案有以下四种,但是在处理无限深度.海量数据的树结构时,都存在一些问题: 1)Adjacency List(邻接表):每个节点仅记录父节点主键.优点是简单,缺点是访问子树需 ...

  5. P2P平台投宝金融跑路?为什么我没有中雷!

    编者按:市场有风险,投资需谨慎.最近,安徽合肥P2P平台"投保金融"跑路倒闭了. 今天(2016年11月8日)下午,在朋友圈看到一个分享,投宝金融跑路了,新闻媒体已经传开了. 这个 ...

  6. java开发划分级别的标准

    一.史诗序: java开发也有一段时间了,整天茫茫碌碌,除了偶尔的小有成就感,剩下的大部分好像都在重复,你是否也遇到了这样的情况? 遇到一个小细节问题,之前不久解决过,现在却是什么都记不起来了 面对每 ...

  7. day 12 列表字典 补充

    1.列表list的遍历 ##### while遍历 需要len(list) list = [11,22,33,44,55] len_list = len(list) i = 0 while i< ...

  8. 【HDU4565】So Easy!

    [HDU4565]So Easy! 题面 要你求 \[ \lceil (a+\sqrt b)^n \rceil \% m \] 其中\(0<a,m<2^{15},(a-1)^2<b& ...

  9. Python小白学习之基础知识(个人笔记)

    介绍while else的使用,这个不常用 格式化输出 while esle ,当循环内有break语句时,不执行else语句,当没有break语句时,执行完while循环,然后执行else下面的语句 ...

  10. HTTP 两种基本请求方法 GET和 POST的区别

    GET方法 1.GET交互方式是从服务器上获取数据,而并非修改数据,所以GET交互方式是安全的.就像数据库查询一样,从数据库查询数据,并不会影响数据库的数据信息,对数据库来说,也就是安全的.2.GET ...