A+B for Input-Output Practice (II)
时间: 1ms 内存:64M
描述:
The first line integer means the number of input integer a and b.
Your task is to Calculate a + b.
输入:
Your task is to Calculate a + b.
The first line integer means the numbers of pairs of input integers.
输出:
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.
示例输入:
2
1 5
10 20
示例输出:
6
30
提示:
参考答案(内存最优[748]):
#include<stdio.h>
int main( )
{
int a,b;
while( scanf("%d %d",&a,&b)!=EOF)
{
if(a==0&&b==0) break;
printf("%d\n",a+b);
}
return 0;
}
参考答案(时间最优[0]):
#include <iostream>
using namespace std;
int main()
{
int a,b,n;
cin>>n;
while(n--)
{
cin >>a>>b;
cout <<a+b<< endl;
}
return 0;
}
题目和答案均来自于互联网,仅供参考,如有问题请联系管理员修改或删除。