- package ch02;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.Arrays;
- public class ch02 {
- int n[],len;
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- String raw[];
-
-
- ch02() throws IOException
- {
- 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);
- for(int i:n)
- System.out.print(i+" ");
- }
-
-
- public static void main(String[] args) throws IOException {
- new ch02();
- }
- }
複製代碼 |