問題描述
給定一個長度爲n的數列,將這個數列按從小到大的順序排列。1<=n<=200
輸入格式
第一行爲一個整數n。
第二行包含n個整數,爲待排序的數,每個整數的絕對值小於10000。
輸出格式
輸出一行,按從小到大的順序輸出排序後的數列。
樣例輸入
5
8 3 6 4 9
樣例輸出
3 4 6 8 9
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
List<Integer> data = new ArrayList<Integer>();
for(int i = 0;i<num;i++) {
data.add(i, scan.nextInt());
}
data.sort(null);
for(int i = 0;i<data.size();i++) {
System.out.print(data.get(i) + " ");
}
}
}