返回列表 發帖
本帖最後由 張瀚仁 於 2014-7-19 14:12 編輯
  1. import java.io.Console;
  2. import java.util.Arrays;
  3. public class ch39
  4. {
  5.     public static void main(String args[])
  6.     {
  7.         int a,b,c,d,e,f,g,h,i,j;
  8.         System.out.println("請任意輸入十個整數");
  9.         Console co=System.console();
  10.         System.out.print("請輸入第一個數:");
  11.         a=Integer.parseInt(co.readLine());
  12.         System.out.print("請輸入第二個數:");
  13.         b=Integer.parseInt(co.readLine());
  14.         System.out.print("請輸入第三個數:");
  15.         c=Integer.parseInt(co.readLine());
  16.         System.out.print("請輸入第四個數:");
  17.         d=Integer.parseInt(co.readLine());
  18.         System.out.print("請輸入第五個數:");
  19.         e=Integer.parseInt(co.readLine());
  20.         System.out.print("請輸入第六個數:");
  21.         f=Integer.parseInt(co.readLine());
  22.         System.out.print("請輸入第七個數:");
  23.         g=Integer.parseInt(co.readLine());
  24.         System.out.print("請輸入第八個數:");
  25.         h=Integer.parseInt(co.readLine());
  26.         System.out.print("請輸入第九個數:");
  27.         i=Integer.parseInt(co.readLine());
  28.         System.out.print("請輸入第十個數:");
  29.         j=Integer.parseInt(co.readLine());
  30.         int n[]={a,b,c,d,e,f,g,h,i,j};
  31.         Arrays.sort(n);
  32.         System.out.print("您剛剛輸入的十個數由小而大依序為:");
  33.         for(int io=0;io<=9;io++)
  34.         {
  35.             System.out.print(n[io]+" ");
  36.         }


  37.     }
  38. }
複製代碼

TOP

返回列表