• <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

            了解了使用string時常犯的錯誤:c_str函數的返回值是const char*的,因此絕對不能scanf("%s",s.c_str());。
            另外題目中建議使用scanf()(本來使用cin/cout一點事情都沒有,結果換了scanf()/printf()發現了這個錯誤)。

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

            class Student
            {
                
            public:
                    Student():sum_score_(
            0) {}
                    
                    
            string name_;
                    
            int sum_score_;
            };

            bool operator<(const Student &a,const Student &b)
            {
                
            return (a.sum_score_>b.sum_score_ || (a.sum_score_==b.sum_score_ && a.name_<b.name_));
            }

            int main()
            {
                
            /*
                freopen("data.in","r",stdin);
                freopen("data.out","w",stdout);
                //
            */
                
                
            int n,m,g;
                
            while(scanf("%d%d%d",&n,&m,&g)==3 && n)
                {
                    
            int score[17];
                    
            for(int i=0;i<m;i++)
                        scanf(
            "%d",&score[i]);
                    
                    Student stu[
            1007];
                    
            int passed(0);
                    
            for(int i=0;i<n;i++)
                    {
                        
            //  Can not use scanf("%s",stu[i].name_.c_str());
                        cin>>stu[i].name_;
                        
            int solved;
                        scanf(
            "%d",&solved);
                        
            for(int j=0;j<solved;j++)
                        {
                            
            int pro_num;
                            scanf(
            "%d",&pro_num);
                            stu[i].sum_score_
            +=score[pro_num-1];
                        }
                        
            if(stu[i].sum_score_>=g)
                            passed
            ++;
                    }
                    
                    sort(stu,stu
            +n);
                    
                    printf(
            "%d\n",passed);
                    
            for(int i=0;i<passed;i++)
                        printf(
            "%s %d\n",stu[i].name_.c_str(),stu[i].sum_score_);
                }
                
            return 0;
            }
            posted on 2011-02-28 23:05 lee1r 閱讀(544) 評論(2)  編輯 收藏 引用 所屬分類: 題目分類:基礎/模擬

            FeedBack:
            # re: HDU 1236 排名
            2011-03-05 20:46 | 貝殼里的海
            這代碼看起來很舒服,哈  回復  更多評論
              
            # re: HDU 1236 排名
            2011-04-04 20:36 | starvae
            @貝殼里的海
            哈哈,竟然在這看到你~~  回復  更多評論
              
            欧美国产精品久久高清| 69久久精品无码一区二区| 久久久免费观成人影院| 色偷偷88欧美精品久久久 | 国产真实乱对白精彩久久| 久久久久国产| 久久久久无码精品国产| 色成年激情久久综合| 久久久久久伊人高潮影院| 亚洲国产精品久久久久婷婷软件 | 少妇被又大又粗又爽毛片久久黑人| 久久亚洲国产精品123区| 亚洲AV无码久久精品狠狠爱浪潮 | 日本福利片国产午夜久久| 思思久久好好热精品国产| 久久国产精品久久国产精品| 色婷婷综合久久久久中文字幕 | 超级碰久久免费公开视频| 日韩精品无码久久久久久| 亚洲精品乱码久久久久久蜜桃| 精品免费久久久久久久| 久久精品国产久精国产果冻传媒| 久久免费美女视频| 久久99国产综合精品免费| 欧美国产成人久久精品| 青青草国产97免久久费观看| 午夜不卡888久久| 国产精品无码久久久久久| 久久精品中文无码资源站| 一本色综合网久久| 亚洲中文字幕久久精品无码喷水| 久久久久亚洲AV无码去区首| 久久精品国产一区二区电影| 99久久精品这里只有精品| 久久精品国产亚洲一区二区三区 | 久久精品中文无码资源站| 模特私拍国产精品久久| 亚洲国产精品无码久久九九| 久久亚洲国产最新网站| 久久夜色精品国产噜噜亚洲a| 久久久久久久久久久|