This is an annoying problem. How do you handle the newline char '\n' in the input stream?
Although my C++ code was accepted, I am not satisfied --- I used cin.peek(). So the qeustion remains to be
1. Can you do it in C?
2. Can you do it without using cin.peek() and/or putback()?
Note that there maybe more than one spaces between two numbers, and there maybe 0 or more spaces before '\n'.
Problem statement:
http://acm.nankai.edu.cn/p1023.html
对于输入的数据进行求和。
Input
输入有多行数据,每行有若干整数,这些整数数以空格分割,请分别求出每行整数的和。
Output
输出的每行对应输入的每行,每行一个数字,即为输入的一行整数之和。
Sample Input
100 200 4
45 45
Sample Output
304
90
[此贴子已经被作者于2007-7-19 8:02:19编辑过]