zoukankan      html  css  js  c++  java
  • 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 (≤), 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 #define _CRT_SECURE_NO_WARNINGS
     2 #include <climits>
     3 #include<iostream>
     4 #include<vector>
     5 #include<queue>
     6 #include<map>
     7 #include<stack>
     8 #include<algorithm>
     9 #include<string>
    10 #include<cmath>
    11 using namespace std;
    12 struct S {
    13     string s1, s2;
    14 };
    15 vector<S> V;
    16 int main()
    17 {
    18     int N;
    19     cin >> N;
    20     string s1, s2;
    21     for (int i = 0; i < N; i++)
    22     {
    23         int flag = 0;
    24         cin >> s1 >> s2;
    25         for (int j = 0; j < s2.length(); j++)
    26         {
    27             if (s2[j] == '1')
    28             {
    29                 flag = 1;
    30                 s2[j] = '@';
    31             }
    32             else if (s2[j] == '0')
    33             {
    34                 flag = 1;
    35                 s2[j] = '%';
    36             }
    37             else if (s2[j] == 'l')
    38             {
    39                 flag = 1;
    40                 s2[j] = 'L';
    41             }
    42             else if (s2[j] == 'O')
    43             {
    44                 flag = 1;
    45                 s2[j] ='o';
    46             }
    47         }
    48         if (flag)
    49             V.push_back({ s1,s2 });
    50     }
    51     if (V.size() == 0)
    52     {
    53         if (N == 1)
    54             cout << "There is 1 account and no account is modified";
    55         else
    56             printf("There are %d accounts and no account is modified", N);
    57     }
    58     else
    59     {
    60         cout << V.size() << endl;
    61         for (auto it : V)
    62             cout << it.s1 << " " << it.s2<<endl;
    63     }
    64 }
    View Code
  • 相关阅读:
    iOS-iOS调用相机调用相册【将图片保存到本地相册】
    iOS-image图片压缩
    iOS-沙盒目录
    iOS-Xcode代码统计
    Django基础之Model操作
    Django objects.all() ,objects.get() ,objects.filter()之间的区别
    django从1.7升级到1.9后 提示:RemovedInDjango110Warning
    关闭TCP中135、139、445、593、1025 等端口的操作方法 (转)(记录下)
    oracle decode函数和 sign函数
    Apache的主要目录和配置文件详解
  • 原文地址:https://www.cnblogs.com/57one/p/12013590.html
Copyright © 2011-2022 走看看