【PAT甲级 map的使用】1035 Password (20 分)

#include<bits/stdc++.h>
using namespace std;

map<char, char> M = {
    {'1', '@'},
    {'0', '%'},
    {'l', 'L'},
    {'O', 'o'}
};

int main() {
    int N;
    queue< pair<string, string> > rst;
    cin >> N;
    for(int i = 0;i < N;++i) {
        string name, password;
        cin >> name >> password;
        bool flag = false;
        for(char &c: password) {
            if(c == '1' || c == '0' || c == 'l' || c == 'O') {
                c = M[c];
                flag = true;
            }
        }
        if(flag) rst.push({name, password});
    }
    if(rst.size()) {
        cout << rst.size() << endl;
        while(!rst.empty()) {
            cout << rst.front().first << " " << rst.front().second << endl;
            rst.pop();
        }
    } else if(N >= 2){
        printf("There are %d accounts and no account is modified\n", N);
    } else 
    if(N == 1) {
        printf("There is %d account and no account is modified\n", N);
    }

    return 0;
}
上一篇:继承Thread类


下一篇:数字IC笔试题(1)