题解 | #简单错误记录#

简单错误记录

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

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

int main() {
    string s;
    vector<string> strs;
    map<string,int> mp;
    while (getline(cin,s)) {
        string tmp="";
        for(auto i:s){
            if(i=='\\'){
                tmp="";
            }else{
                tmp+=i;
            }
        }
        string t = tmp;
        int j;
        for(j = 0;j<t.size()&&t[j]!=' ';j++) ;
        j = j>16?j-16:0;
        tmp = tmp.substr(j);
        if(mp.find(tmp)==mp.end()){
            mp[tmp] = 1;
            strs.push_back(tmp);
        }else{
            mp[tmp]++;
        }
    }
    int begin = strs.size()>8?strs.size()-8:0;
    for(int i = begin;i<strs.size();i++){
        cout<<strs[i]<<" "<<mp[strs[i]]<<endl;
    }

}
// 64 位输出请用 printf("%lld")

这。。。

全部评论

相关推荐

05-29 09:02
门头沟学院 Java
点赞 评论 收藏
分享
水墨不写bug:疑似没有上过大学
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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