题解 | #简单错误记录#

简单错误记录

https://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb

#include <iostream>
#include <sstream>
#include <unordered_map>
#include <vector>

using namespace std;

int main() {
    string str;
    string name, row, key;
    int index = 0;
    vector<string> errV(8, "");
    unordered_map<string, int> errM;
    while (getline(cin, str)) {
        istringstream iss(str.substr(0, str.find(' ')));
        while (getline(iss, name, '\\'));
        int l = name.size();
        if (l > 16) name = name.substr(l - 16);
        row = str.substr(str.find(' ') + 1);
        key = name + " " + row;
        if (errM.find(key) == errM.end()) {
            errM[key] = 1;
            errV[index] = key;
            index = (index + 1) % 8;
        } else {
            errM[key] ++;
        }
    }
    for (int i = 0; i < 8; ++i) {
        if (errV[index] != "") {
            cout << errV[index] << " " << errM[errV[index]] << endl;
        }
        index = (index + 1) % 8;
    }

    return 0;
}

全部评论

相关推荐

不愿透露姓名的神秘牛友
02-16 22:33
杉川机器人 嵌入式工程师 18.0k*13.0, 年终奖1~9个月浮动
点赞 评论 收藏
分享
野猪不是猪🐗:把你的学校加黑,加粗,斜体,下划线,描边,内阴影,内发光,投影,外发光,再上渐变色,居中,放大到最大字号,再把简历里其它内容删了,就行了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务