题解 | #简单错误记录#

简单错误记录

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")

这。。。

全部评论

相关推荐

不愿透露姓名的神秘牛友
03-28 13:48
hory权:校招vip纯神人了,还说自己是什么师范大学的
点赞 评论 收藏
分享
03-26 22:55
门头沟学院 Java
烤冷面在迎接:河南byd,应该就是郑大了。不过24届计算机是特殊情况,那年除了九✌和强2,以及两三个关系够硬的双非,其他的都是炮灰,感觉是十几年来互联网行业最烂的一年,如果想了解最新的就业情况,得找现在的大四。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务