返回列表 發帖
  1. import java.io.*;
  2. import java.util.*;

  3. public class Ch100 {
  4.         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  5.        
  6.         int data[];
  7.         String str[];

  8.         Ch100() throws Exception {
  9.                 System.out.print("請輸入多個整數 (以空白分隔): ");
  10.                 str = br.readLine().split(" ");
  11.                 data = new int[str.length];
  12.                 for (int i = 0; i < str.length; i++)
  13.                         data[i] = Integer.parseInt(str[i]);
  14.                 Arrays.sort(data);
  15.                 for (int i : data)
  16.                         System.out.print(i + " ");
  17.         }

  18.         public static void main(String[] args) throws Exception  {
  19.                 new Ch100();
  20.         }

  21. }
複製代碼

TOP

返回列表