• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            心如止水
            Je n'ai pas le temps
            posts - 400,comments - 130,trackbacks - 0

            還不錯,一次AC。讀入數據時用cin/stringin比較方便處理,輸出時則換用printf。另外注意多關鍵字排序,覺得這題還是使用多次排序比較方便編程。
            以下是我的代碼:

            #include<iostream>
            #include
            <sstream>
            #include
            <vector>
            #include
            <string>
            #include
            <algorithm>
            #include
            <cstdio>
            #include
            <cctype>
            using namespace std;

            struct Type
            {
                Type()
                {
                    name_
            ="";
                    score_
            =win_=lose_=draw_=goal_=all_goal_=game_=0;
                }
                
            string name_;
                
            int score_,win_,lose_,draw_,goal_,all_goal_,game_;
            };

            int n;
            vector
            <Type> r;

            int Team(const string &team_name)
            {
                
            for(int i=0;i<n;i++)
                    
            if(r[i].name_==team_name)
                        
            return i;
            }

            bool cmp_1(const Type &a,const Type &b)
            {
                
            string aa(a.name_),bb(b.name_);
                
            for(int i=0;i<aa.size();i++)
                    aa[i]
            =tolower(aa[i]);
                
            for(int i=0;i<bb.size();i++)
                    bb[i]
            =tolower(bb[i]);
                
            return aa<bb;
            }
            bool cmp_2(const Type &a,const Type &b)
            {
                
            return a.game_<b.game_;
            }
            bool cmp_3(const Type &a,const Type &b)
            {
                
            return a.all_goal_>b.all_goal_;
            }
            bool cmp_4(const Type &a,const Type &b)
            {
                
            return a.goal_>b.goal_;
            }
            bool cmp_5(const Type &a,const Type &b)
            {
                
            return a.win_>b.win_;
            }
            bool cmp_6(const Type &a,const Type &b)
            {
                
            return a.score_>b.score_;
            }

            int main()
            {
                
            int T;
                cin
            >>T;
                getchar();
                
            bool first(true);
                
            while(T--)
                {
                    
            string game_name;
                    getline(cin,game_name);
                    cin
            >>n;
                    getchar();
                    r.resize(n);
                    
            for(int i=0;i<n;i++)
                        getline(cin,r[i].name_);
                    
            int g;
                    cin
            >>g;
                    getchar();
                    
            string s;
                    
            for(int i=0;i<g;i++)
                    {
                        getline(cin,s);
                        
            int pos_1(s.find('#')),pos_2(s.rfind('#'));
                        
            string team_1(s.substr(0,pos_1)),team_2(s.substr(pos_2+1));
                        istringstream sin(s.substr(pos_1
            +1));
                        
            int goal_1,goal_2;
                        sin
            >>goal_1;
                        
            char ch;
                        sin
            >>ch;
                        sin
            >>goal_2;
                        
            int team_1_num(Team(team_1)),team_2_num(Team(team_2));
                        r[team_1_num].all_goal_
            +=goal_1;
                        r[team_1_num].goal_
            +=(goal_1-goal_2);
                        r[team_1_num].game_
            ++;
                        r[team_2_num].all_goal_
            +=goal_2;
                        r[team_2_num].goal_
            +=(goal_2-goal_1);
                        r[team_2_num].game_
            ++;
                        
            if(goal_1>goal_2)
                        {
                            r[team_1_num].score_
            +=3;
                            r[team_1_num].win_
            ++;
                            r[team_2_num].lose_
            ++;
                        }
                        
            else if(goal_1<goal_2)
                        {
                            r[team_2_num].score_
            +=3;
                            r[team_2_num].win_
            ++;
                            r[team_1_num].lose_
            ++;
                        }
                        
            else
                        {
                            r[team_1_num].score_
            ++;
                            r[team_2_num].score_
            ++;
                            r[team_1_num].draw_
            ++;
                            r[team_2_num].draw_
            ++;
                        }
                    }

                    sort(r.begin(),r.end(),cmp_1);
                    stable_sort(r.begin(),r.end(),cmp_2);
                    stable_sort(r.begin(),r.end(),cmp_3);
                    stable_sort(r.begin(),r.end(),cmp_4);
                    stable_sort(r.begin(),r.end(),cmp_5);
                    stable_sort(r.begin(),r.end(),cmp_6);

                    
            if(first)
                        first
            =false;
                    
            else
                        cout
            <<endl;
                    cout
            <<game_name<<endl;
                    
            for(int i=0;i<n;i++)
                        printf(
            "%d) %s %dp, %dg (%d-%d-%d), %dgd (%d-%d)\n",i+1,r[i].name_.c_str(),r[i].score_,r[i].game_,r[i].win_,r[i].draw_,r[i].lose_,r[i].goal_,r[i].all_goal_,r[i].all_goal_-r[i].goal_);

                    fill_n(r.begin(),n,Type());
                }

                
            return 0;
            }
            posted on 2011-04-11 12:02 lee1r 閱讀(728) 評論(0)  編輯 收藏 引用 所屬分類: 題目分類:字符串處理題目分類:排序
            日韩欧美亚洲综合久久影院Ds| 九九久久精品国产| 久久精品国产精品国产精品污| 中文国产成人精品久久不卡| 久久91精品国产91| 国产亚洲综合久久系列| 国产精品日韩深夜福利久久| 婷婷久久精品国产| 日本强好片久久久久久AAA| 99久久精品国产一区二区蜜芽| 国产精品久久久久久久人人看| 午夜不卡久久精品无码免费| 亚洲色欲久久久久综合网| 老司机国内精品久久久久| 日韩精品久久久肉伦网站| 久久e热在这里只有国产中文精品99| 一本色道久久88综合日韩精品| 国产精品美女久久久久网| 久久亚洲AV成人出白浆无码国产| 久久青草国产精品一区| 囯产极品美女高潮无套久久久| 久久国产精品一区二区| 久久久久久曰本AV免费免费| 色婷婷综合久久久久中文字幕| 久久人人妻人人爽人人爽| 亚洲另类欧美综合久久图片区| 亚洲AV无码成人网站久久精品大| 久久久WWW免费人成精品| 欧美日韩精品久久久免费观看| 99久久这里只有精品| 久久午夜羞羞影院免费观看| 亚州日韩精品专区久久久| 久久久久国产精品麻豆AR影院| 色综合久久88色综合天天| 色成年激情久久综合| 国产精品欧美久久久久天天影视| 91精品国产9l久久久久| 亚洲成色999久久网站| A级毛片无码久久精品免费| 国产成人久久精品麻豆一区 | 少妇人妻88久久中文字幕|