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

            FeedBack:
            # re: HDU 1236 排名
            2011-03-05 20:46 | 貝殼里的海
            這代碼看起來很舒服,哈  回復  更多評論
              
            # re: HDU 1236 排名
            2011-04-04 20:36 | starvae
            @貝殼里的海
            哈哈,竟然在這看到你~~  回復  更多評論
              
            久久人人爽人人爽人人片AV东京热| 免费一级做a爰片久久毛片潮| 亚洲AⅤ优女AV综合久久久| 久久久久成人精品无码| 久久久久亚洲AV片无码下载蜜桃 | 久久久久久久女国产乱让韩 | 99精品国产免费久久久久久下载 | 久久无码国产| 香蕉久久夜色精品国产2020| 中文字幕无码免费久久| AV色综合久久天堂AV色综合在| 久久精品国产第一区二区| 伊人久久综合成人网| 久久黄视频| 精品综合久久久久久97超人 | 久久男人中文字幕资源站| 99久久无色码中文字幕人妻| 91精品国产高清久久久久久国产嫩草 | 武侠古典久久婷婷狼人伊人| 久久精品一本到99热免费| 久久久久九九精品影院| 99精品久久久久中文字幕| 欧美日韩精品久久免费| 久久久艹| 亚洲精品综合久久| 久久久久亚洲精品天堂久久久久久 | 亚洲国产天堂久久综合网站| 久久综合狠狠综合久久| 久久无码专区国产精品发布| 久久精品视频91| 国产毛片久久久久久国产毛片 | 国产精品久久久天天影视香蕉| 精品久久8x国产免费观看| 日韩精品无码久久久久久| 国产欧美久久久精品影院| 国内精品久久国产| 欧美黑人激情性久久| 中文无码久久精品| 久久久久亚洲AV无码麻豆| 久久亚洲AV成人无码电影| 久久久精品人妻一区二区三区四|