首页 > 代码库 > 简单桶排序

简单桶排序

 1 #include <stdio.h>
 2 
 3 int main(void){
 4     int book[1001], i, j, t,n;
 5     for (i = 0; i <= 1000; i++)
 6         book[i] = 0;
 7     scanf("%d", &n);
 8     for (i = 0; i < n; i++){
 9         scanf("%d", &t);
10         book[t]++;
11     }
12     for (i = 1000; i >= 0; i--)
13         for (j = 1; j <= book[i]; j++){
14             printf("%d ", i);
15         }
16     getchar();
17     return 0;
18 
19 }

 

简单桶排序