zoukankan      html  css  js  c++  java
  • PAT 甲级 1035 Password (20 分)

    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:

    3
    Team000002 Rlsp0dfa
    Team000003 perfectpwd
    Team000001 R1spOdfa
    

    Sample Output 1:

    2
    Team000002 RLsp%dfa
    Team000001 R@spodfa
    

    Sample Input 2:

    1
    team110 abcdefg332
    

    Sample Output 2:

    There is 1 account and no account is modified
    

    Sample Input 3:

    2
    team110 abcdefg222
    team220 abcdefg333
    

    Sample Output 3:

    There are 2 accounts and no account is modified


     1 #include<iostream>
     2 #include<string>
     3 #include<vector>
     4 
     5 using namespace std;
     6 
     7 bool judge(string& str)
     8 {
     9   bool flag = false;
    10   
    11   for(int i=0;i<str.size();++i)
    12   {
    13     switch(str[i])
    14     {
    15       case '1': str[i] = '@';flag = true;break;
    16       case '0': str[i] = '%';flag = true;break;
    17       case 'l': str[i] = 'L';flag = true;break;
    18       case 'O': str[i] = 'o';flag = true;break;
    19     }
    20   }
    21   
    22   return flag;
    23 }
    24 
    25 int main()
    26 {
    27   int N;
    28   string str1,str2;
    29   vector<string> v;
    30   
    31   cin>>N;
    32   
    33   for(int i=0;i<N;++i)
    34   {
    35     cin>>str1>>str2;
    36     
    37     if(judge(str2))
    38     {
    39       v.push_back(str1);
    40       v.push_back(str2);
    41     }
    42   }
    43   
    44   if(v.size() == 0 && N == 1)
    45     cout<<"There is 1 account and no account is modified"<<endl;
    46   else if(v.size() == 0 && N > 1)
    47     cout<<"There are " << N <<" accounts and no account is modified"<<endl;
    48   else
    49   {
    50     cout<<v.size()/2<<endl;
    51     
    52     for(int i=0;i<v.size();i+=2)
    53       cout<<v[i]<<" "<<v[i+1]<<endl;
    54   }
    55 }
  • 相关阅读:
    Android 8.0编译过程
    Ubuntu下映射网络驱动器
    Android 指定调用已安装的某个“相机”App
    sendMessage 与 obtainMessage (sendToTarget)比较
    Linux tee命令
    Android P(9.0) userdebug版本执行adb remount失败
    adb shell get/setprop, setenforce...
    Bluedroid: 蓝牙协议栈源码剖析
    android o logcat read: unexpected EOF!
    Winform 打包 混淆 自动更新
  • 原文地址:https://www.cnblogs.com/cdp1591652208/p/10229642.html
Copyright © 2011-2022 走看看