- import java.io.Console;
- import java.util.Arraya;
- public class ch40
- {
- public static void main(String args[])
- {
- Console c=System.console();
- System.out.println("請任意輸入10個整數");
- int n[]=new int[10];
- for(int i=0; i<10; i++)
- {
- System.out.print("第"+(i+1)+"個數: ");
- n[i]=Integer.parseInt(c.readLine());
- }
- Arrays.sort(n);
- System.out.print("你剛剛輸入的10個數由小到大依序為: ");
- for(int i=0; i<10; i++)
- System.out.print(n[i]+" ");
- System.out.println();
- }
- }
複製代碼 |