Your task is to Calculate a + b.
标签:
Your task is to Calculate a + b.
The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.
(0<=a,b<=10000)
For each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.
1 5
10 20
6
30
[思路]硬要说的话,就是声明两个int类型的变量,然后记得赋值进去,然后把它们的和输出来,注意EOF的处理,如果利用scanf输入的话,可以写成~scanf(....)碰到EOF就会跳出来啦~!
[代码]
1 #include <iostream> 2 using namespace std; 3 4 int main() 5 { 6 int a , b; 7 while(cin >> a >> b) cout << a + b << endl; 8 return 0; 9 }
标签:
原文地址:http://www.cnblogs.com/ticsmtc/p/5350533.html