- import java.util.Arrays;
- import java.util.Scanner;
- 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]+" ");
- }
- }
- }
複製代碼 |