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.
import java.util.Scanner;
class Main{
private static Scanner sc ;
public static void main(String[] args) {
sc = new Scanner(System.in);
while(sc.hasNext()){
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a+b);
}
}
}
输入两个数,打印其和
hasNext()方法判断时候有下一个输入的数据
while保证有多组数据