返回列表 發帖
本帖最後由 黃博鴻 於 2012-12-1 17:08 編輯
  1. import java.util.*;
  2. public class ch46
  3. {
  4.    public static void main(String args[])
  5.    {
  6.       int a[]=new int[10];
  7.       Scanner input=new Scanner(System.in);
  8.       System.out.println("請輸入10個整數");
  9.       for(int i=0; i<10; i++)
  10.       {
  11.        System.out.print("第"+(i+1)+"個數: ");
  12.        a[i]=input.nextInt();
  13.       }
  14.       Arrays.sort(a);
  15.       System.out.print("您剛剛輸入的10個數由小而大依序為: ");
  16.       for(int i=0; i<10; i++)
  17.       {
  18.        System.out.print(a[i]+" ");
  19.       }
  20.    }
  21. }
複製代碼

TOP

返回列表