1000.A+B Problem
提交状态 耗时 内存 语言 提交时间

1000.A+B Problem

时间限制:1000MS  内存限制:655350KB
题目描述
Calculate A + B,and give me the answer!
输入描述
Input two integers A and B.(Watch the Sample Input)
输出描述
For each case, output A + B in one line..(Watch the Sample Output)
示例
输入样例
1 2
输出样例
3
提示
Press the Submit to submit your code!
Q: Where is the input and the output?
A: Your program shall read input from stdin('Standard Input') and write output to stdout('Standard Output').
For example, you can use 'scanf' in C or 'cin' in C++ to read from stdin, and use 'printf' in C or 'cout' in C++ to write to stdout. User programs are not allowed to open and read from/write to files, you will get a "Restricted Function" if you try to do so.
Here is a sample solution for problem 1000 using C:
#include <stdio.h>
int main(void)
{
    int a,b;
    while(scanf("%d%d", &a,&b) != EOF)
        printf("%d\n",a+b);
    return 0;
}
Here is a sample solution for problem 1000 using C++:
#include <iostream>
using namespace std;
int main(void)
{
    int a,b;
    while(cin >> a>>b)
        cout << a+b<<endl;
    return 0;
}

Here is a sample solution for problem 1000 using Java:

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

相关标签
登陆后才可以提交
测试输入
执行结果
控制台
代码编辑器配置
  • 字体设置
    调整适合你的字体大小。
  • 主题设置
    切换不同的代码编辑器主题,选择适合你的语法高亮。
  • 行宽限制
    设置每一行代码的最大字符个数,设置为0则不限制。