#include<stdio.h>
int main(){
int n=22;
int a[n]={9,8,7,6,5,4,3,2,1,9,8,7,6,5,4,3,2,1,6,4,6,4};
int m=10;
int tong[m];
for(int i=0;i<m;i++){
tong[i]=0;
}
for(int i=0;i<n;i++){
tong[a[i]]++;
}
printf("经过桶排序后:\n");
int i=0;
while(i<m){
while(tong[i]){
printf(" %d",i);
tong[i]--;
}
i++;
}
}
桶排序(时间复杂度为O(m+n))
最新推荐文章于 2024-04-23 05:00:00 发布