首页 > ACM题库 > HDU-杭电 > HDU 1094 A+B for Input-Output Practice (VI)[解题报告] c++
2013
11-27

HDU 1094 A+B for Input-Output Practice (VI)[解题报告] c++

A+B for Input-Output Practice (VI)

问题描述 :

Your task is to calculate the sum of some integers.

输入:

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.

输出:

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.

样例输入:

4 1 2 3 4
5 1 2 3 4 5

样例输出:

10
15

#include<stdio.h>
int main()
{
	int a,i,n,sum;
	while(scanf("%d",&n)!=EOF)
	{
		sum=0;
		for(i=0;i<n;i++)
		{
			scanf("%d",&a);
			sum+=a;
		}
		printf("%d/n",sum);
	}
}

  1. 代码是给出了,但是解析的也太不清晰了吧!如 13 abejkcfghid jkebfghicda
    第一步拆分为 三部分 (bejk, cfghi, d) * C(13,3),为什么要这样拆分,原则是什么?