题解 | #配置文件恢复#

配置文件恢复

https://www.nowcoder.com/practice/ca6ac6ef9538419abf6f883f7d6f6ee5

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

int main() {
    string s;
    vector<string> word = {"reset", "board", "add", "delete", "reboot", "backplane", "abort"};
    while (getline(cin, s)) {
        bool doublepart = false;
        int count = 0;
        string s1, s2;
        while (count != s.size() && s[count] != ' ') {
            s1.push_back(s[count]);
            ++count;
        }
        if (count == s.size()) {
            if (word[0].find(s1) == string::npos) {
                cout << "unknown command" << endl;
                continue;
            } else {
                cout << "reset what" << endl;
                continue;
            }
        }
        ++count;
        while (count != s.size()) {
            s2.push_back(s[count]);
            ++count;
        }
        int flag = 0;
        if (word[0].find(s1) == 0) {
            if (word[1].find(s2) == 0) {
                flag = 2;
            } else {
                cout << "unknown command" << endl;
                continue;
            }
        }
        if (word[1].find(s1) == 0) {
            if (word[2].find(s2) == 0) {
                if (flag != 0) {
                    cout << "unknown command" << endl;
                    continue;
                } else {
                    flag = 3;
                }
            } else if (word[3].find(s2) == 0) {
                if (flag != 0) {
                    cout << "unknown command" << endl;
                    continue;
                } else {
                    flag = 4;
                }
            } else {
                cout << "unknown command" << endl;
                continue;
            }
        }
        if (word[4].find(s1) == 0) {
            if (word[5].find(s2) == 0) {
                if (flag != 0) {
                    cout << "unknown command" << endl;
                    continue;
                } else {
                    flag = 5;
                }
            } else {
                cout << "unknown command" << endl;
                continue;
            }

        }
        if (word[5].find(s1) == 0) {
            if (word[6].find(s2) == 0) {
                if (flag != 0) {
                    cout << "unknown command" << endl;
                    continue;
                } else {
                    flag = 6;
                }
            } else {
                cout << "unknown command" << endl;
                continue;
            }
        }
        if (flag == 0) {
            cout << "unknown command" << endl;
            continue;
        }
        if (flag == 2) {
            cout << "board fault" << endl;
            continue;
        }
        if (flag == 3) {
            cout << "where to add" << endl;
            continue;
        }
        if (flag == 4) {
            cout << "no board at all" << endl;
            continue;
        }
        if (flag == 5) {
            cout << "impossible" << endl;
            continue;
        }
        if (flag == 6) {
            cout << "install first" << endl;
            continue;
        }
    }
}
// 64 位输出请用 printf("%lld")

这题纯傻逼的

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-10 11:55
点赞 评论 收藏
分享
Yki_:你要算时间成本呀,研究生两三年,博士三四年,加起来就五六年了,如果你本科去腾讯干五年,多领五年的年薪,加上公司内涨薪,可能到时候十五年总薪资也跟博士差不多
点赞 评论 收藏
分享
今天 16:52
已编辑
门头沟学院 Java
周五投的,流程今天结束
投递地平线等公司7个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务