import java.util.Scanner; publicclassMain{ publicstaticvoidmain(String[] args){ Scanner input = new Scanner(System.in); while (input.hasNext()) { //注意while处理多个case int a = input.nextInt(); int b = input.nextInt(); System.out.println(a + b); } } }
1 2 3 4 5 6 7 8 9 10 11
import java.util.Scanner; publicclassMain{ publicstaticvoidmain(String[] args){ Scanner input = new Scanner(System.in); int line = input.nextInt(); scanner.nextLine(); for (int i = 0; i < line; i++) { //code } } }