- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.util.Arrays;
- public class Ch100 {
- int n[], len;
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- String raw[];
- Ch100() throws Exception
- {
- System.out.print("請輸入多個整數 (以空白分隔): ");
- raw=br.readLine().split(" ");
- len=raw.length;
- n=new int[len];
- for(int i=0; i<len; i++)
- n[i]=Integer.parseInt(raw[i]);
- Arrays.sort(n);
- System.out.print("排序後: ");
- for(int i=0; i<len; i++)
- System.out.print(n[i]+" ");
- System.out.println();
- }
- public static void main(String[] args) throws Exception {
- new Ch100();
- }
- }
複製代碼 |