桶排序

#include <bits/stdc++.h>
using namespace std;
int main(){
	int m=5;
	cout<<"请输入"<<m<<"个数字排序"<<endl;
	int max=100000;
	int list[max]={0};
	int a;
	for(int i=0;i<m;i++){
		cin>>a;
		list[a]++;
	}
	for(int i=0;i<max;i++){
		if(list[i]!=0){
			for(int j=0;j<list[i];j++){
				cout<<i<<" ";
			}
		}
	}
	return 0;
}

  

posted @ 2024-01-28 10:57  fushuxuan1  阅读(19)  评论(0)    收藏  举报