• <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 閱讀(538) 評論(2)  編輯 收藏 引用 所屬分類: 題目分類:基礎/模擬

            FeedBack:
            # re: HDU 1236 排名
            2011-03-05 20:46 | 貝殼里的海
            這代碼看起來很舒服,哈  回復  更多評論
              
            # re: HDU 1236 排名
            2011-04-04 20:36 | starvae
            @貝殼里的海
            哈哈,竟然在這看到你~~  回復  更多評論
              
            国产精品久久久久9999| 色综合久久久久| 国产成人精品综合久久久久| 国产精品乱码久久久久久软件| 久久亚洲精品无码aⅴ大香 | 2021久久国自产拍精品| 99久久精品国产高清一区二区 | 国产成人精品免费久久久久| 国产99久久久国产精品~~牛| 亚洲国产香蕉人人爽成AV片久久| 无码伊人66久久大杳蕉网站谷歌| 亚洲狠狠综合久久| 色欲久久久天天天综合网| 国产激情久久久久影院小草| 久久成人小视频| 色偷偷888欧美精品久久久| 精品久久久无码人妻中文字幕 | 亚洲国产成人久久综合碰碰动漫3d | 久久线看观看精品香蕉国产| 狠狠色丁香婷婷久久综合五月| 国内精品久久人妻互换| 国产精品久久久久久久人人看 | 久久久久亚洲AV成人网人人网站 | 久久强奷乱码老熟女网站| 免费观看久久精彩视频| 色欲av伊人久久大香线蕉影院| 亚洲第一永久AV网站久久精品男人的天堂AV| 久久精品中文无码资源站| 久久久久久亚洲精品无码| 精品九九久久国内精品| 91久久精一区二区三区大全| 亚洲va久久久噜噜噜久久天堂| 伊人久久一区二区三区无码| 老司机午夜网站国内精品久久久久久久久 | 久久久精品国产免大香伊| 一极黄色视频久久网站| 天天综合久久一二三区| 热久久视久久精品18| 久久中文字幕精品| 中文字幕久久精品无码| 国产aⅴ激情无码久久|