最近想学算法,就去杭电刷题了
打算用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);
}
}
}