你的任务是计算一系列的a+b。
import java.util.Scanner;
public class Main{
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNextInt()){
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a+b);
}
sc.close();
}
}
通过sc.hasNextInt来判断还有没有下一个数,结尾记得sc.close