1794 - 基础输入输出III:A+B

通过次数

0

提交次数

0

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

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

题目输入

输入为每行两个数:a,b,以EOF结束。

题目输出

输出所有a+b的值

输入/输出样例

输入格式

1 2
3 4
5 6

输出格式

3
7
11

C语言解答

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

C++解答

#include<iostream>
using namespace std;
int main(){
	int a,b;
	while(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);
    while(sc.hasNext())
    {
      int i=sc.nextInt();
      int j=sc.nextInt();
      System.out.println(i+j);
    }
  }
}