zoukankan      html  css  js  c++  java
  • PAT 1035. Password

    #include <cstdio>
    #include <cstdlib>
    #include <vector>
    
    using namespace std;
    
    class Item {
    public:
        char uid[12];
        char pwd[12];
    };
    
    char tbl[256];
    
    void init_tbl() {
        for (int i=0; i<256; i++) {
            tbl[i] = i;
        }
        tbl['1'] = '@';
        tbl['0'] = '%';
        tbl['l'] = 'L';
        tbl['O'] = 'o';
    }
    
    int main() {
        int N;
        scanf("%d", &N);
        vector<Item> ids(N);
        vector<int> changed;
        
        init_tbl();
        
        int len = ids.size();
        for (int i=0; i<len; i++) {
            scanf("%s%s", ids[i].uid, ids[i].pwd);
            bool updated = false;
            int k = 0;
            char ch = '';
            while ((ch = ids[i].pwd[k]) != '') {
                if (ch != tbl[ch]) {
                    ids[i].pwd[k] = tbl[ch];
                    updated = true;
                }
                k++;
            }
            if (updated) {
                changed.push_back(i);
            }
        }
        
        int clen = changed.size();
        
        if (clen == 0) {
            if (N != 1) {
                printf("There are %d accounts and no account is modified
    ", N);
            } else {
                printf("There is 1 account and no account is modified
    ");
            }
        } else {
            printf("%d
    ", clen);
            for (int i=0; i<clen; i++) {
                printf("%s %s
    ", ids[changed[i]].uid, ids[changed[i]].pwd);
            }
        }
        
        return 0;
    }

    午间水

  • 相关阅读:
    luogu P1415 拆分数列 序列DP
    [HAOI2015]树上操作
    [SHOI2012]魔法树
    [SCOI2010]连续攻击游戏
    [NOI2016]区间
    简单数论(一)
    iermu爱耳目
    李宇春:会跳舞的文艺青年
    文峰塔很安祥
    技术宅之flappy bird 二逼鸟
  • 原文地址:https://www.cnblogs.com/lailailai/p/4092038.html
Copyright © 2011-2022 走看看