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. Python学习 :常用模块(三)----- 日志记录

    常用模块(三) 七.logging模块 日志中包含的信息应有正常的程序访问日志,还可能有错误.警告等信息输出 python的 logging 模块提供了标准的日志接口,你可以通过它存储各种格式的日志, ...

  2. 20155316 2016-2017-2 《Java程序设计》第9周学习总结

    教材学习内容总结 课堂学习内容 不要上帝类,设计小类 soild设计 开放封闭原则:对扩充开放,对修改封闭 OOD方案 DIP 基耦合 教材学习内容 JDBC架构 交易与隔离层级 RowSet .cl ...

  3. Ubuntu配置android环境

    jdk:http://www.oracle.com/technetwork/cn/java/javase/downloads/index.html 安装JDK的步骤:http://jingyan.ba ...

  4. [并发并行]_[线程模型]_[Pthread线程使用模型之二 工作组work crew]

    Pthread线程使用模型之二工作组(Work crew) 场景 1.一些耗时的任务,比如分析多个类型的数据, 是独立的任务, 并不像 pipeline那样有序的依赖关系, 这时候pipeline就显 ...

  5. Docker入门篇(二)之docker的单主机网络

    Docker 安装时会自动在host上创建三个网络,我们可用 docker network ls命令查看: [root@localhost ~]# docker network ls NETWORK ...

  6. Struts 2(七):国际化

    基于Struts 2的Web应用国际化开发非常简单,其中Struts 2的国际化包括如下几部分:校验提示信息国际化.类型转换提示信息国际化.Action信息国际化以及JSP页面国际化. 第一节 JSP ...

  7. 基于Spring的最简单的定时任务实现与配置(三)--番外篇 cron表达式的相关内容

    本来这篇文章是会跟本系列的前两篇文章一起发布的.但是,昨天在找资料总结的时候遇到了一点意外,就延后了一些. 本篇的内容主要参考了 这篇博文:http://www.cnblogs.com/junrong ...

  8. 区块链技术:每位CEO都应了解

    区块链技术有可能成为一项广泛应用的突破性技术,像蒸汽机.电力或因特网那 样,改变整个社会和经济的运行方式. 对企业而言,信任至关重要.今天,我们基于信任,将钱存放在银行,通过电商企业 网购产品,并且依 ...

  9. 配置文件语言之yaml

    一. Yaml YAML 是一种简洁的非标记语言.YAML以数据为中心,使用空白,缩进,分行组织数据,从而使得表示更加简洁易读. 由于实现简单,解析成本很低,YAML特别适合在脚本语言中使用.列一下现 ...

  10. nginx交替出现404和200

    今天在调试接口的时候,发现一个奇怪的问题,服务器接口交替返回404和200错误. 排查的时候发现nginx下有大量的404错误记录,而tomcat有两个,一个有正常的访问记录,而另一个虽然启动正常,但 ...