题目
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

题目意思
是说1和 l 还有0和o 会让人分不清,所以定了一个规则,将1改为@,将l改为L,将0改为%,将O改为o,这样便区分开。输入一个n,表示有n组数据,检查n组数据里有几组需要按照规则更改,并将其按照规则改好。最后输出,有需要改的,就按照顺序输出。如都不需要更改则按照样例输出。
这里需要注意的是,不需要更改时,只有一个和有多个的输出有点不一样,account和accounts单复数的区别。

代码

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>using namespace std;int main()
{int n,k=0,q=0,sum=0;scanf("%d",&n);char hx[1000][13],mz[1000][13];char a[13],b[13];for(int j=0;j<n;j++){scanf("%s %s",a,b);int flag=0;for(int i=0; i<strlen(b); i++){if(b[i]=='1'){b[i]='@';flag=1;}else if(b[i]=='l'){b[i]='L';flag=1;}else if(b[i]=='0'){b[i]='%';flag=1;}else if(b[i]=='O'){b[i]='o';flag=1;}}if(flag){sum++;strcpy(hx[k++],b);strcpy(mz[q++],a);}}if(sum){printf("%d\n",sum);for(int i=0;i<sum;i++){printf("%s %s\n",mz[i],hx[i]);}}else if(n==1)printf("There is 1 account and no account is modified\n");elseprintf("There are %d accounts and no account is modified\n",n);return 0;
}

PAT甲级1035 Password相关推荐

  1. PAT甲级1035 Password:[C++题解]字符串修改

    文章目录 题目分析 题目链接 题目分析 题目重述: 题目分析: 把需要更改的字母和对应的字母分别存在string中,两者下标索引要对应. 采用 vector来存储< string, string ...

  2. 【PAT甲级】字符串处理及进制转换专题

    目录 字符串处理 PAT甲级 1001 A+B Format (20 分) PAT甲级1005 Spell It Right (20 分) PAT甲级1035 Password (20 分) PAT甲 ...

  3. PAT甲级训练合集(1-70)

    本章题解跳转 考点 P1001 数字的数组表示和处理 P1002 多项式的数组表示和处理 P1003 深度优先搜素 P1004 深度优先搜素 P1005 哈希表 P1006 P1007 数组子区间求和 ...

  4. PAT甲级题目翻译+答案 AcWing(字符串处理)

    1001 A+B Format (20 分) 题意 :将整数转换成标准格式 思路 :从后往前遍历字符串进行模拟,每三个数字加一个逗号,但不能是在最前面加逗号,也不能是加在负号后面 #include & ...

  5. 【最新合集】PAT甲级最优题解(题解+解析+代码)

    以下每道题均是笔者多方对比后, 思考整理得到的最优代码,欢迎交流! 共同成长哇.可以和博主比拼一下谁刷的更快~ 欢迎收藏.欢迎来玩儿 PAT题解目录 题号 标题 题解 分类 使用算法 1001 A+B ...

  6. 【测试点分析】1035 Password (20 分)

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 To prepare for PAT, the judge sometimes has to generate random pa ...

  7. PAT甲级题目对应知识点分类梳理

    PAT甲级的106道题的知识点与对应的题号整理如下,便于做专项练习和巩固! 1.数据结构 可以用STL系列 栈:1051 堆:1098 队列:1014.1056 链表:1032.1052.1074.1 ...

  8. PAT甲级考试题库题目分类

    PAT甲级题目分类 水题 1136.1139.1143.1148 字符串处理 1001.1005.1035.1061.1073.1077.1082. 1108.1140.1152 模拟 1002.10 ...

  9. PAT甲级真题目录(按题型整理)(转自柳神)

    转载自:https://www.liuchuo.net/archives/2502?tdsourcetag=s_pcqq_aiomsg 最短路径 1003. Emergency (25)-PAT甲级真 ...

最新文章

  1. windows10 安装docker
  2. Mysql 於lampp xampp LinuxUbuntu下的配置
  3. python中组合框_PyQt 组合框
  4. Vue 中的compile操作方式
  5. 湖湘杯 | Misc Wp
  6. cgic: 为C语言编写CGI的C函数库
  7. C# 房贷计算器(等本降息)
  8. 【转】C#命名空间与java包的区别分析
  9. tortoisesvn创建部署项目_FrameWork如何进行云托管部署
  10. 洛谷——P2095 营养膳食
  11. 【C++入门】C++ deque类
  12. ace缓存扩展接口_并不是只有 Redis 才可以做缓存
  13. Java 中的枚举 (enum)
  14. Web前端-html页面-网易注册表单,美化及时验证效果
  15. java设置环境变量jre_JRE环境变量配置图解
  16. bzoj 1260涂色 题解
  17. mac上彻底删除 搜狗输入法 鼠须管输入法
  18. 智慧政务说明书 督察督办(八)
  19. 吴恩达创办Coursera是受他启发!74岁老父亲自述终身学习路,8年学完146门课程
  20. 无人驾驶引发的变革比想象的更快,留给车企和老司机的时间已不多

热门文章

  1. 时间序列预测06:CNN时间序列预测模型详解 02 Multi-step CNN、Multivariate Multi-step CNN
  2. 离散化-利用计算机求解y=x,基于边缘的主动轮廓模型——从零到一用python实现snake...
  3. 长时间穿高跟鞋存在健康隐患
  4. 去哪儿网被曝卖假保险 回应:系统故障所致
  5. excel中的数据链接/连接功能使用场景举例(NPS统计)
  6. 软件测试——软件测试理论基础_ni6
  7. 企业微信 微信开发者工具调试问题
  8. 0x7fffffff与0x3f3f3f3f
  9. C++ 格式化字符串方式总结
  10. 关于软件模块化设计方法