Skip to content

Commit 9d8a49b

Browse files
author
lanyuanxiaoyao
committed
修改文件: _posts/2014-10-27-a-b-input-output.md
1 parent eb08492 commit 9d8a49b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
layout: post
3+
title: 1094.A+B for Input-Output Practice (VI)
4+
date: 2014-10-27 19:03
5+
categories: 杭电HDU
6+
tags: [杭电HDU]
7+
---
8+
## Problem
9+
>**Problem Description**
10+
Your task is to calculate the sum of some integers.
11+
**Input**
12+
Input contains multiple test cases, and one case one line. Each case starts with an integer N, and then N integers follow in the same line.
13+
**Output**
14+
For each test case you should output the sum of N integers in one line, and with one line of output for each line in input.
15+
**Sample Input**
16+
4 1 2 3 4
17+
5 1 2 3 4 5
18+
**Sample Output**
19+
10
20+
15
21+
22+
## Solution
23+
```cpp
24+
#include<stdio.h>
25+
int main(void)
26+
{
27+
int n,m,i,sum;
28+
29+
while(scanf("%d",&n)!=EOF){
30+
sum=0;
31+
for(i=0;i<n;i++){
32+
scanf("%d",&m);
33+
sum+=m;
34+
}
35+
printf("%d\n",sum);
36+
}
37+
return 0;
38+
}
39+
```

0 commit comments

Comments
 (0)