PAT a1035题解

来源:互联网 发布:尔康制药 知乎 编辑:程序博客网 时间:2024/05/16 01:02
#include <cstdio>#include <cstring>struct Account{char name[15], password[15];bool isChange = false;  }s[1005];int main(){int n;scanf("%d", &n);for(int i = 0; i < n; i++){scanf("%s %s", s[i].name, s[i].password);for(int j = 0; j < strlen(s[i].password); j++){if(s[i].password[j] == '1'){s[i].password[j] = '@';s[i].isChange = true;}if(s[i].password[j] == '0'){s[i].password[j] = '%';s[i].isChange = true;}if(s[i].password[j] == 'l'){s[i].password[j] = 'L';s[i].isChange = true;}if(s[i].password[j] == 'O'){s[i].password[j] = 'o';s[i].isChange = true;}}}int count = 0;for(int i = 0; i < n; i++){if(s[i].isChange == true){count++;}}if(count == 0){if(n == 1){printf("There is %d account and no account is modified", n);    }    else{    printf("There are %d accounts and no account is modified", n);}}else{printf("%d\n", count);for(int i = 0; i < n; i++){if(s[i].isChange == true){printf("%s %s\n", s[i].name, s[i].password);} }}return 0;} 

原创粉丝点击