【杭电oj1096】A+B for Input-Output Practice (VIII)

亦凉 2022-09-25 06:15 252阅读 0赞

A+B for Input-Output Practice (VIII)

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 138701 Accepted Submission(s): 42471

Problem Description

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

  1. 3
  2. 4 1 2 3 4
  3. 5 1 2 3 4 5
  4. 3 1 2 3

Sample Output

  1. 10
  2. 15
  3. 6

Author

lcy

Recommend

JGShining | We have carefully selected several similar problems for you: 1001 1000 1040 1108 1008

Statistic | Submit | Discuss | Note

  1. #include<stdio.h>
  2. int main() {
  3. int i,j,k,n;
  4. scanf("%d",&n);
  5. while(n--) {
  6. int sum=0;
  7. scanf("%d",&k);
  8. for(int l=0; l<k; l++) {
  9. scanf("%d",&i);
  10. sum+=i;
  11. }
  12. if(n!=0)
  13. printf("%d\n\n",sum);
  14. else
  15. printf("%d\n",sum);
  16. }
  17. return 0;
  18. }

发表评论

表情:
评论列表 (有 0 条评论,252人围观)

还没有评论,来说两句吧...

相关阅读