Dear all
I want to solve this ACM question. The algorithm of solving this
program is so easy but i do not know
how I should read this type of Data from file? because by using "
ifstream " we will get a string.
so how should I separate it?
Question:
Summation is the addition of a set of numbers; the result is their
sum. The "numbers" to be summed may be natural numbers,
complex numbers, matrices, or still more complicated objects.
This problem is simple. Just sum up all the numbers given and
display the required output.
Again, this is an easy question, but you just have to be careful!
INPUT
Each line of input consists of k integers where each non-zero integer
n lies in the range of
-
2147483647 ≤ n < 0 and 0 < n ≤ 2,147,483,647
Each line of input is terminated by the integer 0. Also note that 1 ≤
k ≤ 20.
OUTPUT
Each line of output consists of the number of integers in each input
line (excluding the terminating
zero), followed by the sum of them.
Sample Input
1 2 3 4 5 0
-1 1 -1 0
101 0
Sample Output
5 15
3 –1
1 101
Regards,
Bahador Saket