1035 Password (20分)

2020-02-13  本文已影响0人  量化啦啦啦
image.png
/**
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<string>
#include<vector>

using namespace std;
int N;

int main() {
    cin >> N;
    vector<string> v;
    for (int i = 0; i < N; i++) {
        string name, pwd;
        cin >> name >> pwd;
        int len = pwd.length(), flag = 0;
        for (int j = 0; j < len; j++) {
            switch (pwd[j]) {
                case '1':
                    pwd[j] = '@';
                    flag = 1;
                    break;
                case '0':
                    pwd[j] = '%';
                    flag = 1;
                    break;
                case 'l':
                    pwd[j] = 'L';
                    flag = 1;
                    break;
                case 'O':
                    pwd[j] = 'o';
                    flag = 1;
                    break;
            }
        }
        if (flag) {
            auto tmp = name + " " + pwd;
            v.push_back(tmp);
        }
    }
    int cnt = v.size();//修改过的数量
    if (cnt != 0) {//若修改过一个及以上
        printf("%d\n", cnt);
        for (int i = 0; i < cnt; i++)
            cout << v[i] << 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;
}

上一篇 下一篇

猜你喜欢

热点阅读