Problem Description
Calculate 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
正确提交
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner n1 = new Scanner(System.in);
// Scanner n2= new Scanner(System.in);
while (n1.hasNextInt()) {
int a = n1.nextInt();
int b = n1.nextInt();
System.out.println(a + b);
}
}
}
错误提交:多加入了包
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner n1 = new Scanner(System.in);
// Scanner n2= new Scanner(System.in);
while (n1.hasNextInt()) {
int a = n1.nextInt();
int b = n1.nextInt();
System.out.println(a + b);
}
}
}