1035. Password (20)

来源:互联网 发布:真丝枕套 知乎 编辑:程序博客网 时间:2024/04/30 06:13

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
分析:
(1)建立结构体,中间有个字符比较,记录好一些标着;
(2)小心文字游戏。。。is are 还有复数。。。。
#include <string>#include <iostream>using namespace std;struct account {string id;string pw;int flag;};int main (){int N,i,j;cin>>N;account *ps= new account[N];for (i=0;i<N;i++){cin>>ps[i].id;cin>>ps[i].pw;ps[i].flag=0;}    int mFlag=0;for (i=0;i<N;i++){j=0;while (ps[i].pw[j]!='\0'){if (ps[i].pw[j]=='1'){ps[i].pw[j]='@';ps[i].flag=1;}else if (ps[i].pw[j]=='0'){ps[i].pw[j]='%';ps[i].flag=1;}else if (ps[i].pw[j]=='l'){ps[i].pw[j]='L';ps[i].flag=1;}else if (ps[i].pw[j]=='O'){ps[i].pw[j]='o';ps[i].flag=1;}j++;}if (ps[i].flag==1){mFlag++;}}if (mFlag==0){if(N<=1)cout<<"There is "<<N<<" account and no account is modified";else cout<<"There are "<<N<<" accounts and no account is modified";}else {cout<<mFlag<<endl;for (i=0;i<N;i++){if (ps[i].flag==1){cout<<ps[i].id<<" "<<ps[i].pw<<endl;}}}    delete [] ps;return 0;}



0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 百度粉色衣服被洗变色了怎么办 粉色衣服放进洗衣机洗变色了怎么办 红米note5a应用锁忘了怎么办 索尼手机死机了怎么办不可拆卸电池 华为手机一直停留在开机画面怎么办 5s用11.4太卡了怎么办 华为荣耀5a手机声音小怎么办 牙签卡在手机插卡针里怎么办 捡的华为手机账号激活不了怎么办 华为平板激活手机密码忘了怎么办 捡个华为手机非要激活才能用怎么办 华为手机没激活想重新激活怎么办 华为手机激活总显示系统繁忙怎么办 华为荣耀7i进水了不开机怎么办 华为荣耀手机进水了怎么办开不开机 华为畅享5s变砖怎么办 我的苹果7机身内存满了怎么办 小米5x拆机后屏幕翘边怎么办 苹果手机设备禁止游戏登入怎么办 苹果7plus玩游戏掉频怎么办 孕期牙套子掉了基牙烂掉了怎么办 美团绑定的信用卡过期了怎么办 苹果6s手机开不开机怎么办 换了散热硅胶后还是死机怎么办 华为畅享6s掉啦怎么办 透明塑料壳被太阳晒的发黄怎么办 新买的手机壳有味道怎么办 刚买的手机壳有异味怎么办 bjd 光油把妆蹭掉了一点怎么办 软皮套手机壳如果大了怎么办 苹果手机自带相机拍照会晃屏怎么办 苹果x手机壳拆不下来怎么办 苹果手机5c屏幕没有反应怎么办 玩穿越火线屏幕两边是黑的怎么办? 8g内存只有2g可用怎么办? 三星7e微信分身打不开怎么办? 光猫的网口1不亮怎么办 两年前的发票发现名头有错误怎么办 苹果5s手机通话声音小怎么办 华为全网通手机电信卡打不了怎么办 合约机移动违约不返话费我该怎么办