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

            一道極其簡單的ACM題,為什么第2段代碼通不過測試?
            http://acm.hziee.edu.cn/showproblem.php?pid=1096

            題目
            Your task is to calculate the sum of some integers.

            Input
            Input contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line.

            Output
            For each group of input integers you should output their sum in one line, and you must note that there is a blank line between outputs.

            Sample Input
            3
            4 1 2 3 4
            5 1 2 3 4 5
            3 1 2 3

            Sample Output
            10
            15
            6

            第一段代碼,通過測試
            # include <iostream>
            using namespace std;
            int main()
            {
            ?int m,n,s;
            ?int sum;
            ?cin>>n;
            ?for(int i=0;i<n;i++)
            ?{
            ??if(i)
            ???cout<<endl;
            ??cin>>m;
            ??sum=0;
            ??for(int j=0;j<m;j++)
            ??{
            ???cin>>s;
            ???sum+=s;
            ??}
            ??cout<<sum<<endl;
            ?}
            ?return 0;
            }

            第2段代碼,通不過測試,why?
            #include <iostream>
            #include <vector>
            #include <numeric>
            #include <string>
            #include <sstream>
            using namespace std;
            int main(void)
            {
            int times;
            cin>>times;
            while(times--!=-1){
            ??????? string str;
            ??????? istringstream istr;
            ??????? int temp;

            ??????? getline(cin,str);
            ??????? istr.str(str);
            ??????? vector<int> array;
            ???????
            ??????? bool ignore=true;
            ??????? while(!istr.eof()){
            ?????????? istr>>temp;??????????????????????????
            ?????????? if(ignore==true) {ignore=false;continue;}?????
            ?????????? array.push_back(temp);
            ?????????? }
            ??????? if(!array.empty()) cout<<accumulate(array.begin(), array.end(),0)<<"\n"<<endl;???
            ?}

            return 0;
            }

            有時候第2段代碼會得出奇怪的結果,這是為什么?

            posted on 2006-04-19 01:48 張沈鵬 閱讀(319) 評論(2)  編輯 收藏 引用
            Comments
            • # re: 一道極其簡單的ACM題,為什么第2段代碼通不過測試?
              任我行
              Posted @ 2006-04-20 08:24
              寫的真亂。下面寫法為什么意思?
              bool ignore=true;
              while(!istr.eof()){
              istr>>temp;
              if(ignore==true){
              ignore=false;
              continue;
              }
              array.push_back(temp);
              }
                回復  更多評論   
            • # re: 一道極其簡單的ACM題,為什么第2段代碼通不過測試?
              me
              Posted @ 2006-04-22 16:04
              就是忽略第一個數,把string轉為int放入vector中  回復  更多評論   
             
            国产精品美女久久久网AV| 久久强奷乱码老熟女| 韩国三级中文字幕hd久久精品| 久久国语露脸国产精品电影| 中文字幕一区二区三区久久网站| 天天爽天天狠久久久综合麻豆| 久久99热这里只有精品66| 狠狠人妻久久久久久综合蜜桃| 国产成人精品免费久久久久| 亚洲综合伊人久久综合| 亚洲伊人久久综合影院| 久久伊人影视| 亚洲?V乱码久久精品蜜桃 | 久久人妻AV中文字幕| 久久综合九色欧美综合狠狠| 韩国三级中文字幕hd久久精品 | 久久久精品午夜免费不卡| 久久青青草原亚洲av无码app| 国产成人精品久久| 国产精品99久久久精品无码| 亚洲va中文字幕无码久久| 人妻无码久久一区二区三区免费| 国内精品久久久久久久久电影网| 久久久久亚洲av成人网人人软件| 99久久免费国产精品特黄| 久久91精品国产91| 久久久久国产精品熟女影院| 久久66热人妻偷产精品9| 国产精品久久久久无码av| 88久久精品无码一区二区毛片 | 国内精品久久久久久野外| 国产91久久精品一区二区| 久久久久久久尹人综合网亚洲| 久久精品一区二区| 少妇久久久久久被弄到高潮| 亚洲日韩中文无码久久| 久久91精品国产91久久户| 久久e热在这里只有国产中文精品99 | 久久久久久久久久久免费精品| 久久婷婷五月综合成人D啪| 漂亮人妻被中出中文字幕久久|