Board logo

標題: ????? [打印本頁]

作者: 許逸瑋    時間: 2012-9-8 16:14     標題: ?????

  1. import java.io.BufferedReader;
  2. import java.io.InputStreamReader;
  3. public class TQC103 {
  4.         public static void main(String[] args) {
  5.         BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  6.         System.out.println("請輸入育產生之亂數:");
  7.         try{
  8.                 String ss = bf.readLine();
  9.                 int num = Integer.valueOf(ss);
  10.                 int[] rnd = new int[num];
  11.                 for(int i = 0; i < num; i++){
  12.                         rnd[i] = (int)(Math.random()*1000);
  13.                         for(int i1 = 1 ; i1 < num; i1++){
  14.                                 for(int j = 0; j < i; j++){
  15.                                         if(rnd[j] > rnd[i])
  16.                                         int t  = rnd[j];
  17.                                         rnd[j] = rnd[i];
  18.                                         rnd[i] = t;
  19.                                 }for(int i2 = 0; i2 < num; i2++)
  20.                                 System.out.printf("%3d\t" + rnd[i]);
  21.                         }
  22.                 }
  23.         }catch(Exception e)
  24.         {
  25.                 System.out.println("請輸入一個正整數");
  26.         }

  27.         }
  28. }
複製代碼
錯誤訊息為:/ I) w3 d  y- r8 l( [8 S" _! b# x
5 H7 M0 Q6 z9 M! P) q
Syntax error on token "int", delete this token! g8 X2 [- j9 w+ D
        t cannot be resolved to a variable
# K6 r6 @2 u2 R4 I0 l# L0 a        t cannot be resolved to a variable( u# ^  [. w. F4 t; A! m

) {5 {% C9 j3 E8 Z        at TQC103.main(TQC103.java:16)




歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/) Powered by Discuz! 7.2