PAT甲级1035

LZ1225 LZ1225 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
1035. Password (20)

时间限制
400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue
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<stdio.h>
#include<string.h>
#include<math.h>

int main(){
char Team[20],PIN[20],store[20][40];
int n,N,flag,i,j,k;
int len1,len2;

while(scanf("%d",&n)!=EOF){
N=0;
for(i=0;i<n;i++){
flag=0;
scanf("%s%s",&Team,&PIN);
len1=strlen(Team);
len2=strlen(PIN);
for(j=0;j<len2;j++){
if(PIN[j]=='0'){
PIN[j]='%';
flag=1;}
else if(PIN[j]=='1'){
PIN[k]='@';
flag=1;}
else if(PIN[j]=='o'){
PIN[k]='O';
flag=1;}
else if(PIN[j]=='l'){
PIN[j]='L';
flag=1;}
}
if(flag==1){
for(k=0;k<len1;k++) store[N][k]=Team[k];
store[N][k]=' ';
for(k=0;k<len2;k++) store[N][k+len1]=PIN[k];
store[N][len1+len2]='\n';
N++;
}
}
if(N==0)printf("There is %d account and no account is modified\n",n);
else {
printf("%d\n",N+1);
for(i=0;i<=N;i++){
for(j=0;j<len1+len2+1;j++){
printf("%c",store[i][j]);
}
printf("\n");
}
}
}
return 0;
}



[调试的时候有“Unhandled exception at 0x012038fd in 甲1035.exe: 0xC0000005: Access violation writing location 0xcce8c928.”,没有语法错误可是也不知道哪里错了,拜托大家看一下!!谢谢谢谢了!
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
LZ1225
C语言 70,040 成员 243,237 内容