本帖最後由 黃博鴻 於 2012-12-1 17:08 編輯
- import java.util.*;
- public class ch46
- {
- public static void main(String args[])
- {
- int a[]=new int[10];
- Scanner input=new Scanner(System.in);
- System.out.println("請輸入10個整數");
- for(int i=0; i<10; i++)
- {
- System.out.print("第"+(i+1)+"個數: ");
- a[i]=input.nextInt();
- }
- Arrays.sort(a);
- System.out.print("您剛剛輸入的10個數由小而大依序為: ");
- for(int i=0; i<10; i++)
- {
- System.out.print(a[i]+" ");
- }
- }
- }
複製代碼 |