返回列表 發帖

?????

  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. }
複製代碼
錯誤訊息為:3 B) U/ l5 y6 F7 e

1 G2 M% Z9 B- @5 x- ]) X% s! c$ nSyntax error on token "int", delete this token- H) V7 t" l) }; U2 c0 _2 b6 H
        t cannot be resolved to a variable
% T; F* W( g4 a. n5 v2 s# }: M        t cannot be resolved to a variable
7 w, V; }7 d' z( T
' a& a* A( j, g; F4 t. ^9 F        at TQC103.main(TQC103.java:16)

返回列表