PAT甲级 1035 -- 没有注释
来源:互联网 发布:win7管理网络密码 编辑:程序博客网 时间:2024/05/17 23:51
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:
3Team000002 Rlsp0dfaTeam000003 perfectpwdTeam000001 R1spOdfaSample Output 1:
2Team000002 RLsp%dfaTeam000001 R@spodfaSample Input 2:
1team110 abcdefg332Sample Output 2:
There is 1 account and no account is modifiedSample Input 3:
2team110 abcdefg222team220 abcdefg333Sample Output 3:
There are 2 accounts and no account is modified
#include <iostream>#include <stdio.h>#include <vector>#include <string>using namespace std;struct node{ char name[11]; char pass[11];}person[1001];bool replace(char name[],char pass[],int cur){ int i=0; bool flag=false; while(name[i]!='\0'){ person[cur].name[i]=name[i]; i++; } person[cur].name[i]='\0'; i=0; while(pass[i]!='\0'){ if(pass[i]=='1')pass[i]='@',flag=true; else if(pass[i]=='0')pass[i]='%',flag=true; else if(pass[i]=='l')pass[i]='L',flag=true; else if(pass[i]=='O')pass[i]='o',flag=true; person[cur].pass[i]=pass[i]; i++; } person[cur].pass[i]='\0'; return flag;}int main(){ //freopen("./in","r",stdin); int n; scanf("%d",&n); int i; int count=0; char name[11],pass[11]; for(i=0;i<n;i++){ scanf("%s%s",name,pass); if(replace(name,pass,count)){ count++; } } if(count==0){ if(n==1) printf("There is %d account and no account is modified\n",n); else printf("There are %d accounts and no account is modified\n",n); return 0; } printf("%d\n",count); for(i=0;i<count;i++){ printf("%s %s\n",person[i].name,person[i].pass); } return 0;}
- PAT甲级 1035 -- 没有注释
- PAT甲级 1034 -- 没有注释
- PAT甲级 1036 -- 没有注释
- PAT甲级 1037 -- 没有注释
- PAT甲级 1038 -- 没有注释
- PAT(甲级)1035
- 浙大PAT甲级 1035
- PAT甲级1035
- PAT 甲级
- PAT甲级 1018 没有AC,也不想重做这题
- PAT甲级 1021 没有AC,留着重做
- PAT甲级 A1025.PAT RANKING
- PAT 甲级 1025 PAT Ranking
- PAT(甲级)1003
- PAT(甲级)1004
- PAT(甲级)1005
- PAT(甲级)1006
- PAT(甲级)1007
- Ubuntu 16.04+ROS+ORB-SLAM2配置以及相关问题
- 基本操作及概念
- 暑假第一周D,E,F题
- java多线程之守护线程和用户线程
- Liunx用户与组
- PAT甲级 1035 -- 没有注释
- 剑指offer之变态跳台阶
- nosql简记
- Android开发 之 补间动画
- grpc-简单的客户端服务端通信(1)
- 【(类似DP)优化】 分梨子
- java面向对象的三大特征:封装-继承-多态
- 【 用漫画图解贝叶斯公式】-- 我家狗叫的时候,是不是有小偷进门了?告诉我。
- origion绘制热图