zoukankan      html  css  js  c++  java
  • pat1035. Password (20)

    1035. Password (20)

    时间限制
    400 ms
    内存限制
    65536 kB
    代码长度限制
    16000 B
    判题程序
    Standard
    作者
    CHEN, Yue

    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<cstdio>
     2 #include<stack>
     3 #include<algorithm>
     4 #include<iostream>
     5 #include<stack>
     6 #include<set>
     7 #include<map>
     8 #include<vector>
     9 using namespace std;
    10 vector<string> v;
    11 map<string,string> ha;
    12 bool check(char &c){
    13     if(c=='1'){
    14         c='@';
    15         return true;
    16     }
    17     if(c=='0'){
    18         c='%';
    19         return true;
    20     }
    21     if(c=='l'){
    22         c='L';
    23         return true;
    24     }
    25     if(c=='O'){
    26         c='o';
    27         return true;
    28     }
    29     return false;
    30 }
    31 int main(){
    32     //freopen("D:\INPUT.txt","r",stdin);
    33     int n;
    34     scanf("%d",&n);
    35     int i,j;
    36     string num,pas;
    37     int count=0;
    38     for(i=0;i<n;i++){
    39         cin>>num>>pas;
    40         bool can=false;
    41         for(j=0;j<pas.length();j++){
    42             if(check(pas[j])){
    43                 can=true;
    44             }
    45         }
    46         if(can){
    47             count++;
    48             v.push_back(num);
    49             ha[num]=pas;
    50         }
    51     }
    52     if(count){
    53         printf("%d
    ",count);
    54         for(j=0;j<v.size();j++){
    55             cout<<v[j]<<" "<<ha[v[j]]<<endl;
    56         }
    57     }
    58     else{
    59         if(n==1){
    60             printf("There is 1 account and no account is modified
    ",n);
    61         }
    62         else{
    63             printf("There are %d accounts and no account is modified
    ",n);
    64         }
    65     }
    66     return 0;
    67 }
  • 相关阅读:
    Python学习笔记(2)
    Python学习笔记(1)
    2020年5月记于博茨瓦纳
    20145208 蔡野 《网络对抗》免考项目 MSF学习
    20145208 蔡野 《网络对抗》Exp9 web安全基础实践
    20145208 蔡野 《网络对抗》Exp8 Web基础
    20145208 蔡野 《网络对抗》Exp7 网络欺诈技术防范
    20145122 《Java程序设计》课程总结
    20145122《 Java网络编程》实验五实验报告
    20145122 《Java程序设计》第十周学习总结
  • 原文地址:https://www.cnblogs.com/Deribs4/p/4782220.html
Copyright © 2011-2022 走看看