我的Java程序正在输入n-1行。它跳过了最后一行

时间:2018-10-05 16:23:19

标签: java

我的Java程序:

janitor

我的输入:

import java.util.Scanner;

public class ChefAndCook {
 public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int testCases = sc.nextInt();

    for(int i = 0; i < testCases; i++) {
        String input = sc.nextLine();
        System.out.println(input);
    }
 }
}

我的输出:

3
1 3 2
0 3 2
34 55 2

为什么跳过最后一行?为什么不打印第三行34 55 2? 我在其他地方读到了我的程序可能正在输入的信息。我该如何解决这个问题?

0 个答案:

没有答案