返回列表 發帖
  1. import java .util.Arrays;
  2. import java .io.Console;
  3. public class ch45
  4. {
  5.     public static void main(String args[])
  6.     {
  7.       int a[]=new int[10];
  8.       Console c=System.console();
  9.       System.out.println("請任意輸入10個整數");
  10.       for(int i=0; i<10; i++)
  11.       {
  12.               System.out.print("第"+(i+1)+"個數: ");
  13.               a[i]=Integer.parseInt(c.readLine());
  14.       }
  15.       Arrays.sort(a);
  16.       System.out.println("你剛輸入的十個數字由小到大依序為: ");
  17.       for(int i=0; i<=9; i++)
  18.       {
  19.         System.out.print(a[i]+"  ");
  20.       }
  21.     }
  22. }
複製代碼

TOP

返回列表