HDU-1000 A + B Problem 解题报告

最近想学算法,就去杭电刷题了

打算用JAVA来做

题很简单,主要就是要了解提交格式

开始不了解提交格式,a+b都错了几遍

提交格式:

1.不带包名

2.类名为:Main

3.循环输入为:
 

Scanner sc = new Scanner(System.in);
	while(sc.hasNext()){

        }

知道这三点便可以解决这道题了

代码:

import java.util.Scanner;

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

}

猜你喜欢

转载自blog.csdn.net/Timo_Max/article/details/81303666