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 replace1 (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 <algorithm>
     3 #include <cstdio>
     4 #include <cstring>
     5 #include <map>
     6 #include <stack>
     7 #include <vector>
     8 #include <queue>
     9 #include <set>
    10 #define LL long long
    11 using namespace std;
    12 const int MAX = 20, MAXN = 1e3 + 10;
    13 
    14 struct node
    15 {
    16     char s1[MAX], s2[MAX];
    17 }P[MAXN];
    18 char buf1[MAX], buf2[MAX];
    19 int n, cnt = 0;
    20 map <char, char> mp;
    21 
    22 
    23 bool is_ans()
    24 {
    25     bool flag = false;
    26     int len = strlen(buf2);
    27     for (int i = 0; i < len; ++ i)
    28     {
    29         if (mp.find(buf2[i]) != mp.end())
    30         {
    31             buf2[i] = mp[buf2[i]];
    32             flag = true;
    33         }
    34     }
    35     if (flag) return true;
    36     return false;
    37 }
    38 
    39 int main()
    40 {
    41 //    freopen("Date1.txt", "r", stdin);
    42     mp['l'] = 'L', mp['O'] = 'o', mp['1'] = '@', mp['0'] = '%';
    43     scanf("%d", &n);
    44     for (int i = 1; i <= n; ++ i)
    45     {
    46         scanf("%s %s", &buf1, &buf2);
    47         if (is_ans())
    48         {
    49             strcpy(P[cnt].s1, buf1);
    50             strcpy(P[cnt ++].s2, buf2);
    51         }
    52     }
    53     if (cnt != 0)
    54     {
    55         printf("%d
    ", cnt);
    56         for (int i = 0; i < cnt; ++ i)
    57             printf("%s %s
    ", P[i].s1, P[i].s2);
    58         return 0;
    59     }
    60     if (n == 1)
    61         printf("There is 1 account and no account is modified
    ");
    62     else
    63         printf("There are %d accounts and no account is modified
    ", n);
    64     return 0;
    65 }
  • 相关阅读:
    Delphi程序流程三(2)(while)PS:最简单的任务管理器( 组件LISTVIEW的用法 增加LISTVIEW的读取 删除)
    Delphi 编译错误信息表(转载自万一博客)
    Delphi程序流程三(1)(while)PS:顺便写了个最简单的任务管理器(包含申明API 自己申明参数为结构型API 组件LISTVIEW的用法)
    Delphi程序流程二(for)
    内核编程 warning C4273: 'PsGetProcessId' : inconsistent dll linkage
    简单的SEH处理
    【转】VC6.0各个文件说明
    【转】两篇关于__security_cookie的介绍
    完美解决 error C2220: warning treated as error
    【转】IDA 与VC 加载符号表
  • 原文地址:https://www.cnblogs.com/GetcharZp/p/9589514.html
Copyright © 2011-2022 走看看