zoukankan      html  css  js  c++  java
  • 简单错误记录

    #include<iostream>
    #include<string>
    #include<list>
    using namespace std;
    
    struct record{
        string name;
        int line;
        int count;
    };
    
    string getname(string str)
    {
        int sz = str.length();
        int i;
        for(i=sz-1;  i>=0 && str[i]!='\'; i-- );
    
        if(sz-1-i>16)
            return str.substr(sz-16);
        else
            return str.substr(i+1);
    }
    
    int main()
    {
        list<record> listrd;
        string str;
        int num;
        while(cin>>str>>num)
        {
            string name = getname(str);
            int line = num;
            record rd;
    
            bool exist = false;
            for(list<record>::iterator itr=listrd.begin(); itr!=listrd.end(); itr++)
            {
                if((*itr).name == name && (*itr).line == line)
                {
                    exist = true;
                    (*itr).count++;
                }
            }
            if(exist==false)
            {
                if(listrd.size()==8)
                {
                    listrd.pop_front();
                }
                rd.name = name;
                rd.line = line;
                rd.count = 1;
                listrd.push_back(rd);
            }
        }
    
        for(list<record>::iterator itr=listrd.begin(); itr!=listrd.end(); itr++)
        {
            cout<<(*itr).name<<' '<<(*itr).line<<' '<<(*itr).count<<endl;
        }
    
        return 0;
    }
  • 相关阅读:
    hdu 2196(树上点分治)
    hdu 4807(网络流 + 贪心)
    hdu4101
    hdu4216
    hdu 4219, 树形概率DP
    hdu 4127 A*搜索
    hdu 4126
    hdu 5296,15年多校1-7
    poj3436 ACM Computer Factory
    Fence
  • 原文地址:https://www.cnblogs.com/hardsoftware/p/6231029.html
Copyright © 2011-2022 走看看