PAT 甲级 A1035 (2019/02/10)
Posted zjsaipplp
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PAT 甲级 A1035 (2019/02/10)相关的知识,希望对你有一定的参考价值。
1 #include<cstdio> 2 #include<cstring> 3 struct user{ 4 char id[20]; 5 char password[20]; 6 bool ischange; 7 }List[1001]; 8 bool isalter(user &t, int &count){//1 (one) by @, 0 (zero) by %, l by L, and O by o 9 int len = strlen(t.password); 10 for(int i = 0; i < len; i++){ 11 if(t.password[i] == ‘1‘){ 12 t.password[i] = ‘@‘; 13 t.ischange = true; 14 }else if(t.password[i] == ‘0‘){ 15 t.password[i] = ‘%‘; 16 t.ischange = true; 17 }else if(t.password[i] == ‘l‘){ 18 t.password[i] = ‘L‘; 19 t.ischange = true; 20 }else if(t.password[i] == ‘O‘){ 21 t.password[i] = ‘o‘; 22 t.ischange = true; 23 } 24 } 25 if(t.ischange == true) 26 count++; 27 } 28 int main(){ 29 int N, count = 0; 30 scanf("%d", &N); 31 for(int i = 0; i < N; i++){ 32 scanf("%s%s", List[i].id, List[i].password); 33 List[i].ischange = false; 34 } 35 for(int j = 0; j < N; j++) 36 isalter(List[j], count); 37 if(count == 0){ 38 if(N == 1) printf("There is %d account and no account is modified",N); 39 else printf("There are %d accounts and no account is modified",N-count); 40 }else{ 41 printf("%d ", count); 42 for(int i = 0; i < N; i++) 43 if(List[i].ischange == true) 44 printf("%s %s ",List[i].id,List[i].password); 45 } 46 return 0; 47 }
以上是关于PAT 甲级 A1035 (2019/02/10)的主要内容,如果未能解决你的问题,请参考以下文章