import java.util.Scanner;
public class java{
public static void main(String[] args){
Scanner str=new Scanner(System.in);
int a, b,i,j;
while (str.hasNext()){
i=str.nextInt(); j=str.nextInt();
a=str.nextInt(); b=str.nextInt();
System.out.println(i+j);
System.out.println(a+b);
}
}
}
結果 *** 第 1 點 (10%):RE)
執行時發生錯誤(code:1)!!
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:817)
at java.util.Scanner.next(Scanner.java:1431)
at java.util.Scanner.nextInt(Scanner.java:2040)
at java.util.Scanner.nextInt(Scanner.java:2000)
at code_472871.main(code_472871.java:12)
*** 第 2 點 (90%):AC (108ms, 5.7MB)
import java.util.Scanner;
public class java{
public static void main(String[] args){
Scanner str=new Scanner(System.in);
int a, b,i,j;
while (str.hasNext()){
i=str.nextInt(); j=str.nextInt();
a=str.nextInt(); b=str.nextInt();
System.out.println(i+j);
System.out.println(a+b);
}
}
}
結果 *** 第 1 點 (10%):RE)
執行時發生錯誤(code:1)!!
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:817)
at java.util.Scanner.next(Scanner.java:1431)
at java.util.Scanner.nextInt(Scanner.java:2040)
at java.util.Scanner.nextInt(Scanner.java:2000)
at code_472871.main(code_472871.java:12)
*** 第 2 點 (90%):AC (108ms, 5.7MB)
你是一次讀 4 個數字 ?
那就不對囉
如果測資只有3筆 ? 像這樣
1 2
2 4
6 7
--> 這裡會讀不到東西