码迷,mamicode.com
首页 > 其他好文 > 详细

PAT 甲级 A1035 (2019/02/10)

时间:2019-02-21 23:11:27      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:cst   string   i++   password   pat   span   user   count   print   

 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\n", count);
42         for(int i = 0; i < N; i++)
43         if(List[i].ischange == true)
44             printf("%s %s\n",List[i].id,List[i].password);
45     }    
46     return 0;
47 } 

 

PAT 甲级 A1035 (2019/02/10)

标签:cst   string   i++   password   pat   span   user   count   print   

原文地址:https://www.cnblogs.com/zjsaipplp/p/10415834.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!