杭电oj-1000(A+B Problem)
2016-08-08 本文已影响458人
关玮琳linSir
Problem Description
alculate A + B.
Input
Each line will contain two integers A and B. Process to end
of file.
Output
For each case, output A + B in one line.
Sample Input
1 1
Sample Output
2
Author
HDOJ
简述一下哈,最近真是无聊,真是没事干,所以打算每天抽出几个小时来做做题,正直七夕哈,祝大家有情人终成眷属,表白的都成功,我打算敲一天代码,new一天对象,😄O(∩_∩)O哈哈~
当然这是最简单的一道题啦,所以我就不说思路咯,说一下用java A题的应该注意的事项:
1.必须要导包,千万不能忘记了
2.类名必须为Main
3.要注意输入、输出的格式
代码:
import java.util.Scanner;
public class Main1000 {
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);
}
}
}