PAT甲级1035
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
[调试的时候有“Unhandled exception at 0x012038fd in 甲1035.exe: 0xC0000005: Access violation writing location 0xcce8c928.”,没有语法错误可是也不知道哪里错了,拜托大家看一下!!谢谢谢谢了!
时间限制
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.”,没有语法错误可是也不知道哪里错了,拜托大家看一下!!谢谢谢谢了!
...全文
相关推荐
pat题目分类.docx
这些PAT甲级题目涵盖了多个计算机科学的基础知识点,主要包括字符串处理、哈希表的应用、图论问题和树结构的处理。接下来我们将对这些知识点进行详细解释。1.
PAT_100:PAT甲级的91题AC代码
这里的"91题"表示是PAT甲级考试中的第91道题目。"AC代码"指的是实现这道题目算法并已通过所有测试用例的源代码,"AC"代表"Accepted",意味着代码已经成功解决题目需求。
PAT乙级 1035 插入与归并
《PAT乙级 1035 插入与归并》这道编程题主要考察的是对两种基本排序算法——插入排序和归并排序的理解与应用。题目给出两个整数序列,一个是未排序的序列(c),另一个是部分排序后的中间结果(m)。
cpp_somepats_
文件名如pat1020.cpp、patb1035.cpp等,一般情况下,PAT题目编号前的"a"或"b"表示题目难度,"a"类题相对简单,"b"类题则较难。
JEP30-PX100A PartModel Product Guidelines for Electronic-Device Substrates and Assemblies – XML Requ
JEP30-PX100A PartModel Product Guidelines for Electronic-Device Substrates and Assemblies – XML Requirements


