• <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
            @貝殼里的海
            哈哈,竟然在這看到你~~  回復  更多評論
              
            91久久婷婷国产综合精品青草| 热久久最新网站获取| 五月丁香综合激情六月久久| 久久人爽人人爽人人片AV| 久久久精品午夜免费不卡| 国产三级观看久久| 无码国内精品久久综合88| 中文字幕无码精品亚洲资源网久久 | 久久精品国产99久久久| av午夜福利一片免费看久久| 久久精品国产精品亜洲毛片 | 韩国三级大全久久网站| 久久久99精品一区二区| 东京热TOKYO综合久久精品| 久久99热这里只有精品66| 亚洲国产精品久久久久| 亚洲国产一成人久久精品| 久久国产成人午夜aⅴ影院 | 无码超乳爆乳中文字幕久久| 久久久久久久久久免免费精品| 久久精品国产99久久无毒不卡 | 久久久久久久综合综合狠狠| 久久99久久99精品免视看动漫| 久久久久国产精品三级网| 色成年激情久久综合| 亚洲欧美精品伊人久久| 久久亚洲2019中文字幕| 久久最近最新中文字幕大全| 人妻无码αv中文字幕久久琪琪布| 精品久久久久久中文字幕| 久久精品国产乱子伦| 久久综合伊人77777麻豆| 久久99精品久久久久久9蜜桃| 99久久免费国产特黄| 99久久国产综合精品麻豆| 天堂久久天堂AV色综合| 亚洲中文字幕无码久久精品1| 久久久久久久免费视频| yy6080久久| 无码AV波多野结衣久久| 久久久老熟女一区二区三区|