题解 | #简单错误记录#

简单错误记录

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

#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <deque>

using namespace std;

int main() {
    string str;
    map<string,int> m;
    deque<string> dq;
    while(getline(cin,str)){
        str+=' ';
        vector<string> v;
        string temp;
        
        size_t nprev=0;
        size_t n = str.find(' ');
        temp = str.substr(0,n);
        v.push_back(temp);
        nprev=n;
        n=str.find(' ',nprev+1);
        temp = str.substr(nprev+1,n-nprev-1);
        v.push_back(temp);
        size_t x = v[0].find_last_of('\\');
        temp = v[0].substr(x+1);
        if((v[0].size()-x-1)>16){
            temp=v[0].substr(v[0].size()-16);
        }
        temp+=' '+v[1];
        if(m.find(temp)==m.end()) dq.push_back(temp);
        ++m[temp];
        if(dq.size()>8)    dq.pop_front();
        
        
    }
    for(auto &it:dq){
        cout<<it<<' '<<m[it]<<endl;
    }
    
    
    
    
}
全部评论

相关推荐

想按时下班的我在等o...:我投测试也是这个情况,不知道咋办了
点赞 评论 收藏
分享
05-30 12:03
山西大学 C++
offer来了我跪着...:不是骗子,等到测评那一步就知道为啥这么高工资了
点赞 评论 收藏
分享
大飞的诡术妖姬:之前看b站多明海有个说法,日本就业竞争非常低的原因不光是毕业学生少,还有很多人干两年不喜欢职场氛围就辞职躺平,位置也空了很多,论吃苦耐劳还得看咱们
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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