PAT甲级 1035 -- 没有注释

来源:互联网 发布:win7管理网络密码 编辑:程序博客网 时间:2024/05/17 23:51

1035. Password (20)

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:

3Team000002 Rlsp0dfaTeam000003 perfectpwdTeam000001 R1spOdfa
Sample Output 1:
2Team000002 RLsp%dfaTeam000001 R@spodfa
Sample Input 2:
1team110 abcdefg332
Sample Output 2:
There is 1 account and no account is modified
Sample Input 3:
2team110 abcdefg222team220 abcdefg333
Sample Output 3:
There are 2 accounts and no account is modified


#include <iostream>#include <stdio.h>#include <vector>#include <string>using namespace std;struct node{    char name[11];    char pass[11];}person[1001];bool replace(char name[],char pass[],int cur){    int i=0;    bool flag=false;    while(name[i]!='\0'){        person[cur].name[i]=name[i];        i++;    }    person[cur].name[i]='\0';    i=0;    while(pass[i]!='\0'){        if(pass[i]=='1')pass[i]='@',flag=true;        else if(pass[i]=='0')pass[i]='%',flag=true;        else if(pass[i]=='l')pass[i]='L',flag=true;        else if(pass[i]=='O')pass[i]='o',flag=true;        person[cur].pass[i]=pass[i];        i++;    }    person[cur].pass[i]='\0';    return flag;}int main(){    //freopen("./in","r",stdin);    int n;    scanf("%d",&n);    int i;    int count=0;    char name[11],pass[11];    for(i=0;i<n;i++){        scanf("%s%s",name,pass);        if(replace(name,pass,count)){            count++;        }    }    if(count==0){        if(n==1) printf("There is %d account and no account is modified\n",n);        else printf("There are %d accounts and no account is modified\n",n);        return 0;    }    printf("%d\n",count);    for(i=0;i<count;i++){        printf("%s %s\n",person[i].name,person[i].pass);    }    return 0;}
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 婴儿被蜜蜂蜇了怎么办 婴儿被黄蜂蛰了怎么办 蜜蜂在石头缝里怎么办 中蜂蜂王不产卵怎么办 冲电器充电变慢怎么办 摇号审核通过后怎么办 京东白条开不了怎么办 得了病心里压力大怎么办 电视家看直播卡怎么办 日上提货单丢了怎么办 想直飞香港l签怎么办 u盘识别不出来怎么办 卫生间下水道有小飞虫怎么办 橙光一直闪退怎么办 若白回来了,长安怎么办 没了你以后我该怎么办 玩cf的时候闪退怎么办 婴儿嗓子哭哑了怎么办 宝宝嗓子哭哑了怎么办 小孩嗓子哭哑了怎么办 孩子嗓子哭哑了怎么办 月经来了晚上漏怎么办 在学校月经漏了怎么办 月经来了血下不来怎么办 想让月经快点来怎么办 孩子来月经不规律怎么办 一个月来2次月经怎么办 14岁月经不规律怎么办 不是经期内裤有黑色血怎么办 月经量多血块多怎么办 网友见面没上她怎么办 拔完智齿老流血怎么办 学车教练不教怎么办 想开奶茶店没有经验怎么办 宝宝吃多了不消化怎么办 吃了糖精和鸡蛋怎么办 小米平板2太卡了怎么办 小米平板2卡顿怎么办 小米4黑屏没反应怎么办 小米5c开不了机怎么办 小平板开不了机怎么办