zoukankan      html  css  js  c++  java
  • A1035. Password

    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<iostream>
     3 using namespace std;
     4 int main(){
     5     int N, modfi[1001] = {0}, count = 0;
     6     char acc[1001][11], pwd[1001][11];
     7     scanf("%d", &N);
     8     for(int i = 0; i < N; i++){
     9         scanf("%s%s",acc[i], pwd[i]);
    10         for(int j = 0; pwd[i][j] != ''; j++){
    11             if(pwd[i][j] == '1'){
    12                 pwd[i][j] = '@';
    13                 modfi[i] = 1;
    14             }else if(pwd[i][j] == '0'){
    15                 pwd[i][j] = '%';
    16                 modfi[i] = 1;
    17             }else if(pwd[i][j] == 'l'){
    18                 pwd[i][j] = 'L';
    19                 modfi[i] = 1;
    20             }else if(pwd[i][j] == 'O'){
    21                 pwd[i][j] = 'o';
    22                 modfi[i] = 1;
    23             }
    24         }
    25         if(modfi[i] == 1)
    26             count++;
    27     }
    28     if(count == 0){
    29         if(N == 1)
    30             printf("There is 1 account and no account is modified");
    31         else
    32             printf("There are %d accounts and no account is modified", N);
    33     }else{
    34         printf("%d", count);
    35         for(int i = 0; i < N; i++)
    36             if(modfi[i] == 1)
    37                 printf("
    %s %s", acc[i], pwd[i]);
    38     }
    39     cin >> N;
    40     return 0;
    41 }
    View Code
  • 相关阅读:
    英文半字节压缩编码技术
    博弈翻硬币游戏
    POJ 2015 Permutation Code
    8051、ARM和DSP指令周期的测试与分析
    Huffman编码
    CentOS 命令提示符颜色及样式详解
    JAVA程序员面试32问
    面向抽象编程:接口和抽象类
    初学实用:实例讲解Java中的接口的作用
    C#和Java的区别
  • 原文地址:https://www.cnblogs.com/zhuqiwei-blog/p/8442566.html
Copyright © 2011-2022 走看看