1793 - 基础输入输出II:A+B

通过次数

0

提交次数

0

时间限制 : 1 秒 内存限制 : 128 MB

此题为练手用题,用于大家熟悉最为基础的输入输出操作,请大家计算一下a+b的值。

题目输入

输入第一行为一个整数n,代表数据组数。

第二行开始每行有两个数,a,b,一共有n行数据。

题目输出

输出所有a+b的值

输入/输出样例

输入格式

3
1 1
2 9
1 99

输出格式

2
11
100

C语言解答

#include<stdio.h>
int main()
{
    int a,b,n;
    scanf("%d",&n);
    while(n--){
        scanf("%d%d",&a,&b);
        printf("%d\n",a+b);
    }
    return 0;
}

C++解答

#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n--){
		int a,b;
		cin>>a>>b;
		cout<<a+b<<endl;
	}
}

Java解答

import java.util.Scanner;
public class Main
{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int t=sc.nextInt();
    while(t-->0)
    {
     int a=sc.nextInt();
     int b=sc.nextInt();
     System.out.println(a+b); 
    }
  }
}