1035.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

代碼

#include <iostream>
#include <vector>
#include <string>
using namespace std;
struct node {
    string id, pwd;
};
int main() {
    int n;
    string id, pwd;
    scanf("%d", &n);
    vector<node> stu;
    for (int i = 0; i < n; i++) {
        cin >> id >> pwd;
        int flag = 0;
        for (int i = 0; i < pwd.length(); i++) {
            switch (pwd[i]) {
            case '1':pwd[i] = '@'; flag = 1; break;
            case '0':pwd[i] = '%'; flag = 1; break;
            case 'l':pwd[i] = 'L'; flag = 1; break;
            case 'O':pwd[i] = 'o'; flag = 1; break;
            default: break;
            }
        }
        if (flag) stu.push_back(node{ id,pwd });
    }
    int cnt = stu.size();
    if (cnt != 0) {
        printf("%d\n", cnt);
        for (int i = 0; i < cnt; i++) cout << stu[i].id << " " << stu[i].pwd << endl;
    }
    else if (n == 1) printf("There is 1 account and no account is modified");
    else printf("There are %d accounts and no account is modified", n);
    return 0;
}
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,854評(píng)論 0 10
  • **2014真題Directions:Read the following text. Choose the be...
    又是夜半驚坐起閱讀 11,110評(píng)論 0 23
  • 2019 1.18 星期五 天氣晴 今天孩子放假了!漫長(zhǎng)的假期從周一開始了! 今晚上開家長(zhǎng)...
    往事隨風(fēng)_452e閱讀 296評(píng)論 1 1
  • 以撒年老,眼睛昏花,看不見東西了;(創(chuàng)世記 27:1 新譯本) 以撒是敬畏神的人,他身上有很多的優(yōu)點(diǎn):順服...
    wakeup王閱讀 2,124評(píng)論 0 0
  • 10.21先試試表達(dá)攻擊性 本周主要圍繞著攻擊性去講解的,而攻擊性就相當(dāng)于負(fù)能量一樣或者一些情緒一樣可能會(huì)在不自...
    徐猛_Merlin閱讀 275評(píng)論 0 0

友情鏈接更多精彩內(nèi)容