zoukankan      html  css  js  c++  java
  • ccf-201403-3有趣的命令行

    傻逼题,要是考试只能得0分。。
    提供几组傻逼数据,这要是在真实的生活中一定是错的。。。

    还是要好好读题吧,全凭自己的感觉就得0分

    albw:x
    4
    ls -a docu
    Case 1: -a
    ls -w -w
    Case 2: -w -w
    
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<iostream>
    #include<queue>
    #include<cmath>
    #include<map>
    #include<stack>
    #include<set>
    #include<bitset>
    
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<int, int> pii;
    #define pb(x) push_back(x)
    #define cls(x, val) memset(x, val, sizeof(x))
    #define fi first
    #define se second
    #define mp(x, y) make_pair(x, y)
    #define inc(i, l, r) for(int i=l; i<=r; i++)
    const int inf = 0x3f3f3f3f;
    const int maxn = 2000+10;
    bool have[maxn];
    bool exist[maxn];
    struct Node{
        string s;
        string var;
        bool prin;
    }node[26];
    int n;
    vector<string> split;
    
    vector<string> process(char *s){
        int st = 0;
        vector<string> temp;
        string t;
        int len = strlen(s);
        for(int i=0; i<len; i++){
            if(s[i] == ' '){
                t = "";
                for(int j=st; j<i; j++){
                    t+=s[j];
                }
                temp.push_back(t);
                st = i+1;
            }
        }
        t = "";
        for(int j=st; j<len; j++){
            t+=s[j];
        }
        temp.push_back(t);
        return temp;
    }
    
    int main(){
        ios::sync_with_stdio(false);
        char op[300];
        scanf("%s", op);
        int len = strlen(op);
        for(int i=0; i<len; i++){
            if(op[i]>='a'&&op[i]<='z'){
                exist[op[i]-'a'] = true;
                if(i+1<len && op[i+1] == ':'){
                    have[op[i]-'a'] = true;
                    i++;
                }
            }
        }
    
    
        int kase = 1;
        scanf("%d", &n);
        getchar();
        while(n--){
            gets(op);
            for(int i=0; i<26; i++) node[i].prin = false;
            split = process(op);
    
            int sz = split.size();
    //        for(int i=0; i<sz; i++){
    //            printf("%s ", split[i].c_str());
    //        }
            for(int i=1; i<sz; i++){
                string temp = split[i];
                if(temp[0] == '-'){
                    int c = temp[1]-'a';
                    if(!exist[c]) break;
                    if(have[c] == true){
                        if(i==sz-1) break;
                        else {
                            node[c].prin = true;
                            node[c].var = split[i+1];
                        }
                        i++;
                    }
                    else{
                        node[c].prin = true;
                    }
    
                }
                else break;
            }
            //cout<<"Case "<<kase++<<":";
            printf("Case %d:", kase++);
            for(int i=0; i<26; i++){
                if(node[i].prin){
                    //cout<<" -"<<char(i+'a');
                    printf(" -%c", char(i+'a'));
                    if(have[i]){
                        //cout<<" "<<node[i].var;
                        printf(" %s", node[i].var.c_str());
                    }
                }
    
            }
            printf("
    ");
        }
        return 0;
    }
    
    
    
    
  • 相关阅读:
    bs4--基本使用
    UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 167: illegal multibyte sequence
    linux系统安全审计简单设置
    系统安全设置部分项
    启用系统登录失败处理功能
    系统口令复杂度设置
    正则表达式
    python中的内置函数(bytearray)
    python中的内置函数(2)
    python中的内置函数(一)
  • 原文地址:https://www.cnblogs.com/babydragon/p/11715731.html
Copyright © 2011-2022 走看看