- import java.util.Scanner;
- import java.util.Arrays;
- public class Ch01
- {
- public static void main(String[] args)
- {
- Scanner s=new Scanner(System.in);
- String x[]=new String[10];
- System.out.println("請輸入10個字母");
- for(int i=0; i<10; i++)
- {
- System.out.print("第"+(i+1)+"個:");
- x[i]=s.nextLine();
- }
- Arrays.sort(x);
- System.out.println("您剛剛輸入的10個字母由小到大排列依序為: ");
- for(int i=0; i<10; i++)
- {
- System.out.print(x[i]+" ");
- }
- }
- }
複製代碼 |