返回列表 發帖
  1. import java.util.Scanner;
  2. import java.util.Arrays;
  3. public class Ch01
  4. {
  5.     public static void main(String[] args)
  6.     {
  7.         Scanner s=new Scanner(System.in);
  8.         String x[]=new String[10];
  9.         System.out.println("請輸入10個字母");
  10.         for(int i=0; i<10; i++)
  11.         {
  12.         System.out.print("第"+(i+1)+"個:");
  13.         x[i]=s.nextLine();
  14.         }
  15.         Arrays.sort(x);
  16.         System.out.println("您剛剛輸入的10個字母由小到大排列依序為: ");
  17.         for(int i=0; i<10; i++)
  18.         {
  19.             System.out.print(x[i]+" ");
  20.         }
  21.     }
  22. }
複製代碼

TOP

返回列表