美文网首页
2019-08-27 A1035 Password

2019-08-27 A1035 Password

作者: JO炮 | 来源:发表于2019-08-28 10:27 被阅读0次

这道题对我来说有些困难,用了很长时间(并看了柳神的代码)才解决,下面这个blog是对vector容器的各种函数的介绍:
https://blog.csdn.net/ak201605050122/article/details/80225297

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

int main() {
    vector<string> v;
    int n;
    scanf("%d", &n);
    for(int j = 0; j < n; j++){
        string name, s;
        cin >> name >> s;
        int flag = 0;
        for(int i = 0; i < s.length(); i++){
            switch(s[i]) {
                case '1' : s[i] = '@'; flag = 1; break;
                case '0' : s[i] = '%'; flag = 1; break;
                case 'l' : s[i] = 'L'; flag = 1; break;
                case 'O' : s[i] = 'o'; flag = 1; break;
            }
        }
        if(flag){
            string temp = name + " " + s;
            v.push_back(temp);
        }
    }
        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;
}

相关文章

网友评论

      本文标题:2019-08-27 A1035 Password

      本文链接:https://www.haomeiwen.com/subject/zkmdectx.html