- import java.io.BufferedReader;
- import java.io.InputStreamReader;
- import java.util.Arrays;
- public class Ch100 {
- String tmp;
- int n[], len;
- BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
- Ch100() throws Exception
- {
- System.out.print("請輸入多個整數 (以空白分隔): ");
- tmp=br.readLine();
- len=tmp.split(" ").length;
- n=new int[len];
- for(int i=0; i<len; i++)
- n[i]=Integer.parseInt(tmp.split(" ")[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();
- }
- }
複製代碼 |