桶排序是最简单的排序方法,其代码如下:
#include <stdio.h>
using namespace std;
int main()
{
int book[1001], t, n;
for(int i = 0; i <= 1000; i++){
book[i] = 0;
}
scanf("%d", &n);
for(int i = 1; i <= n; i++){
scanf("%d", &t);
book[t]++;
}
for(int i = 1000; i >= 0; i--){
for(int j = 1; j <= book[i]; j++){
printf("%d ", i);
}
}
getchar();getchar();
return 0;
}
来源:CSDN
作者:小喵没有小鱼干吃
链接:https://blog.csdn.net/qq_44865242/article/details/104044497