星空's Blog
星空's Blog
PAT-A1035 Password

原题

Password (20 分)

题解

白给题

代码

#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

int main(void) {
    int n;
    map<string,string> m;
    vector<string> v;
    cin >> n;
    for (int i = 0;i < n;i++) {
        string userName;
        string password;
        cin >> userName >> password;
        bool isModified = false;
        for (int j = 0;j < password.length();j++) {
            if (password[j] == '1') {
                password[j] = '@';
                isModified = true;
            } else if (password[j] == '0') {
                password[j] = '%';
                isModified = true;
            } else if (password[j] == 'l') {
                password[j] = 'L';
                isModified = true;
            } else if (password[j] == 'O') {
                password[j] = 'o';
                isModified = true;
            }
        }
        if (isModified) {
            v.push_back(userName);
            m[userName] = password;
        }
    }

    int size = v.size();
    if (size) {
        cout << size << endl;
        for (auto it : v) {
            cout << it << " " << m[it] << endl;
        }
    } else {
        if (n > 1) {
            cout << "There are " << n << " accounts and no account is modified" << endl;
        } else {
            cout << "There is " << n << " account and no account is modified" << endl;
        }
    }
    return 0;
}
所有文章禁止转载。
代码仅供参考
为了对抗广告机器人,首次留言将会被审核
首页      算法学习      PAT-A      PAT-A1035 Password
https://secure.gravatar.com/avatar/271861a23dcdde929d3ee8cb8c04f854?s=256&d=monsterid&r=g

星空

文章作者

发表评论

textsms
account_circle
email

星空's Blog

PAT-A1035 Password
原题 Password (20 分) 题解 白给题 代码 #include <iostream> #include <string> #include <map> #include <vector> using namespace std; int main(void) { …
扫描二维码继续阅读
2019-08-31
分类
标签云