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

PAT 甲级 A1035 (2019/02/10)

时间:2019-02-24 10:30:58      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:nts   cstring   printf   str   sch   isa   %s   use   char   

#include<cstdio>
#include<cstring>
struct user{
    char id[20];
    char password[20];
    bool ischange;
}List[1001];
//1 (one) by @, 0 (zero) by %, l by L, and O by o
bool isalter(user &t, int &count){  
    int len = strlen(t.password);
    for(int i = 0; i < len; i++){
        if(t.password[i] == '1'){
            t.password[i] = '@';
            t.ischange = true;
        }else if(t.password[i] == '0'){
            t.password[i] = '%';
            t.ischange = true;
        }else if(t.password[i] == 'l'){
            t.password[i] = 'L';
            t.ischange = true;
        }else if(t.password[i] == 'O'){
            t.password[i] = 'o';
            t.ischange = true;
        }
    }
    if(t.ischange == true)
        count++;
}
int main(){
    int N, count = 0;
    scanf("%d", &N);
    for(int i = 0; i < N; i++){
        scanf("%s%s", List[i].id, List[i].password);
        List[i].ischange = false;
    }
    for(int j = 0; j < N; j++)
        isalter(List[j], 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 - count);  
    }else{
        printf("%d\n", count);
        for(int i = 0; i < N; i++)
        if(List[i].ischange == true)
            printf("%s %s\n",List[i].id, List[i].password);
    }   
    return 0;
} 

PAT 甲级 A1035 (2019/02/10)

标签:nts   cstring   printf   str   sch   isa   %s   use   char   

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

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