A+B for Input-Output Practice (V)
2020-03-30 07:34
1036 查看
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 with one line of output for each line in input.
Sample Input
2
4 1 2 3 4
5 1 2 3 4 5
Sample Output
10
15
C
#include <stdio.h> #pragma warning(disable:4996) int main(void) { int N,M,digit,i,sum; scanf("%d",&N); while(N--) { scanf("%d",&M); for(sum=0,i=0;i<M;i++) { scanf("%d",&digit); sum+=digit; } printf("%d\n",sum); } return 0; }
没什么要说的,注意sum的值归0.
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- Hdoj 1092 A+B for Input-Output Practice (IV)
- HDU 1.1.8 A+B for Input-Output Practice (VIII)
- HDOJ 【C】 1.1.1 A+B for Input-Output Practice (I)
- HDOJ 【C】 1.1.4 A+B for Input-Output Practice (IV)
- HDOJ 1091: A+B for Input-Output Practice (III)
- A+B for Input-Output Practice (VI)
- hduoj1089(A+B for Input-Output Practice (I))
- HDU 1091 A+B for Input-Output Practice (III)(水~)
- HDOJ 1094 A+B for Input-Output Practice (VII)
- A+B for Input-Output Practice (III)
- [水题][hdoj_1089]A+B for Input-Output Practice (I)
- hdoj 1091 A+B for Input-Output Practice (III)
- 1092 A+B for Input-Output Practice(IV)
- hdu1091 - A+B for Input-Output Practice (III)
- 杭电 ACM 1090:A+B for Input-Output Practice (II)
- A+B for Input-Output Practice (VIII)
- 【杭电oj】1096 - A+B for Input-Output Practice (VIII)
- hdu 1095 A+B for Input-Output Practice (VII)
- A+B for Input-Output Practice (VII)
- A+B for Input-Output Practice (V)