Problem1008--A+B Problem

1008: A+B Problem

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

计算 a+b

Input

两个整数 a和b (0<=a,b<=10)

Output

输出a+b 的值

Sample Input Copy

1 2

Sample Output Copy

3

HINT

你的程序应该包含输入的语句和输出的语句。 比如,在C语言中,你可以使用scanf语句输入、用printf语句输出;在C++语言中,你可以使用cin语句输入、用cout语句输出。
你不可以输出问题需要的答案以外的数据,否则,你的程序会被系统判定为"Wrong Answer"。
你的程序也不可以使用文件读写操作,否则,你的程序会被系统判定为"Runtime Error"或者"Wrong Answer"。


这是一个使用C++/G++语言的程序: 
#include <iostream> using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    cout << a+b << endl;
    return 0; //在C++程序中,非常重要的一点是,要返回一个int类型的整数,否则你可能会被系统判定为compile error”,也就是编译错误。
}



以下是一个C语言的程序:
#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a, &b);
    printf("%d\n",a+b);
    return 0;
}

以下是一个PASCAL语言的程序: 
program p1000(Input,Output); 
var 
  a,b:Integer; 
begin 
   Readln(a,b); 
   Writeln(a+b); 
end.

以下是一个JAVA语言的程序(jdk1.5版本): 
import java.io.*;
import java.util.*;
public class Main
{
            public static void main(String args[]) throws Exception
            {
                    Scanner cin=new Scanner(System.in);
                    int a=cin.nextInt();
                    int b=cin.nextInt();
                    System.out.println(a+b);
            }
}

以下是一个JAVA语言的程序(jdk1.4版本):
import java.io.*;
import java.util.*;

public class Main
{
    public static void main (String args[]) throws Exception
    {
        BufferedReader stdin = 
            new BufferedReader(
                new InputStreamReader(System.in));

        String line = stdin.readLine();
        StringTokenizer st = new StringTokenizer(line);
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        System.out.println(a+b);
    }
}

Source/Category

入门