题解 | #简单错误记录#

简单错误记录

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

#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
int main(int argc,char* argv[])
{
    map<string,int> mp;
    vector<pair<string,string> >vec;
    string inputStr;
    while(getline(cin, inputStr))
    {
        int pos1=inputStr.find(" ");
        int pos2=inputStr.rfind("\\");
        string row=inputStr.substr(pos1+1);
        string file=inputStr.substr(pos2+1,pos1-pos2-1);
        if(file.length()>16) file=file.substr(file.length()-16);
        string key=file+"_"+row;
        if(mp.count(key)==0)
        {
            mp[key]=1;
            vec.push_back(make_pair(file,row));
        }else{
            mp[key]++;
        }
    }
    int i=vec.size()>8 ? vec.size()-8:0;
    for(;i<vec.size();i++)
    {
        string key=vec[i].first+"_"+vec[i].second; 
        cout<<vec[i].first.c_str()<<" "<<vec[i].second.c_str()<<" "<<mp[key]<<endl;
    }
    return 0;
}
全部评论

相关推荐

有担当的灰太狼又在摸鱼:零帧起手查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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