zoukankan      html  css  js  c++  java
  • ACM——A + B Problem (4)

    A + B Problem (4)

    时间限制(普通/Java):1000MS/3000MS          运行内存限制:65536KByte
    总提交:2496            测试通过:1249

    描述

    Calculate the sum of some integers.

    输入

    The input will consist of multiple test cases. Each test case consist of an integer N and then N integers following in the same line,separated by a space. A line starting with 0 terminates the input and this line is not to be processed.

    输出

    For test case, you should output their sum in one line, and with one line of output for each line in input. After each test case output, you should output one blank line.

    样例输入

    4 1 2 3 4
    5 1 2 3 4 5
    0

    样例输出

    10

    15

    题目来源

    HDUOJ

     

    #include<iostream>
    #include<vector>
    using namespace std;
    int main(){
        int i,a,b;
        vector<int> ivec;
        int sum=0;
        while(cin>>a)
        {
            if(a==0)
                break;
            for(i=0;i<a;i++)
            {
                cin>>b;
                sum+=b;
            }
            ivec.push_back(sum);
            sum=0;
        }
        for(i=0;i<ivec.size();i++)
            cout<<ivec[i]<<endl<<endl;
        return 0;
    }

     

     

  • 相关阅读:
    唯一索引 && 主键索引
    部分函数依赖 && 完全函数依赖
    范式
    BST树、B树、B+树、B*树
    哈希表
    Bzoj4569: [Scoi2016]萌萌哒
    Bzoj 4551: [Tjoi2016&Heoi2016]树
    Bzoj3631: [JLOI2014]松鼠的新家
    HDU4746: Mophues
    BZOJ2820:YY的GCD
  • 原文地址:https://www.cnblogs.com/BasilLee/p/3791831.html
Copyright © 2011-2022 走看看