作者d1288999 (@凌凌七@)
看板java
標題[問題] 想請問這段編譯哪裡有問題??
時間Thu Apr 19 23:33:44 2012
import java.io.
import java.util.*;
public class test12 {
public static void main(String[] args){
System.out.println("請輸入九個數字");
int[] x = new int[9];
Scanner sc = new Scanner(new BufferedInputStream(System.in));
while(sc.hasNext()) {
for(int i=0;i<9;i++){
x[i]=sc.nextInt();
}
}
}
}
我想把輸入的九個數字,
例如
1 2 3 4 5 6 7 8 9
丟到x陣列中
但是程式一跑之後,就沒反應了
不知道是什麼問題??
有大大可以幫我解答嗎??
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.243.182.13
推 slalala:先搞清楚sc.hasNext()的邏輯吧 04/20 00:19
→ ssc24:被while包住,所以程式不會停止, 04/20 11:17
推 risker760915:1.多出個不明用途的while 2.建議用try catch檢查輸入 04/20 14:17