import java.util.Scanner;
import java.util.Arrays;
public class RadixSort{
public static Scanner sc = new Scanner(System.in);
public static void main(String args[]){
while(sc.hasNext()){
int n = sc.nextInt();
int[] temp = new int[n];
for(int i = 0; i < n; i++){
temp[i] = sc.nextInt();
}
Arrays.sort(temp);
int[] num = new int[10];
int[][] bucket = new int[10][n];
for(int j = n-1; j >= 0; j--){
int lsd = temp[j] % 10;
bucket[lsd][num[lsd]] = temp[j];
num[lsd]++;
}
int m = 0;
for(int k = 0; k < 10; k++){
if(num[k] != 0){
for(int l =0; l < num[k]; l++){
temp[m] = bucket[k][l];
m++;
}
}
}
for(int o : temp){
System.out.print(o + " ");
}
System.out.println();
}
}
}
沒有留言:
張貼留言