又见A+B怎么做

来源:百度知道 编辑:UC知道 时间:2024/06/05 14:50:42
Problem Description

求2个整数之和。

Input
在第一行输入测试组数n,后面n行每行2个整数a,b。

Output
输出n行,每行对应是一个a+b之和。

Sample Input
3
1 2
3 4
5 6

Sample Output
3
7
11

#include<iostream>
using namespace std;

int main()
{
int num = 0;
cin>>num;
int *pStore = new int[num];
for(int i=0; i<num; i++)
{
int x, y;
cin>>x>>y;
pStore[i] = x+y;
}
for(int j=0; j<num; j++)
{
cout<<pStore[j]<<endl;
}
system("pause");
return 0;
}

#include <stdio.h>

int main(){
int loop,a,b;
scanf("%d",&loop);
while(loop--){
scanf("%d %d",&a,&b);
printf("%d\n",a+b);
}
return 0;
}