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

            FeedBack:
            # re: HDU 1236 排名
            2011-03-05 20:46 | 貝殼里的海
            這代碼看起來很舒服,哈  回復  更多評論
              
            # re: HDU 1236 排名
            2011-04-04 20:36 | starvae
            @貝殼里的海
            哈哈,竟然在這看到你~~  回復  更多評論
              
            亚洲AV无码成人网站久久精品大| 久久精品国内一区二区三区| 久久九九久精品国产| 久久精品国产精品亚洲人人| 久久涩综合| 久久人人爽人人人人片av| 蜜臀av性久久久久蜜臀aⅴ| 久久国产综合精品五月天| 国产精品成人久久久| www.久久热| 久久精品国产亚洲av麻豆色欲| 人妻丰满?V无码久久不卡| 精品免费久久久久国产一区| 国产国产成人精品久久| 久久天天躁狠狠躁夜夜av浪潮 | 国产AV影片久久久久久| 久久人人爽人人爽人人片AV不 | 久久久久九国产精品| 欧美午夜精品久久久久免费视| 久久久久亚洲精品无码网址| 国产精品久久亚洲不卡动漫| 久久精品国产亚洲AV影院 | 77777亚洲午夜久久多喷| 一本久久免费视频| 欧美国产精品久久高清| 国产精品久久99| 国产成人久久激情91| 精品熟女少妇av免费久久| 精品国产VA久久久久久久冰| 亚洲精品乱码久久久久久自慰| 一级a性色生活片久久无| 亚洲美日韩Av中文字幕无码久久久妻妇| 中文字幕亚洲综合久久| 久久精品无码av| 久久久久无码中| 人妻少妇精品久久| 久久久久久精品成人免费图片| 综合久久久久久中文字幕亚洲国产国产综合一区首 | 国产精品久久久久蜜芽| 久久亚洲中文字幕精品一区| 一级女性全黄久久生活片免费 |