新桶排序

#include <bits/stdc++.h>
using namespace std;
class t{
	private:
		int a;
		int list[10000]={0};
	public:
	void set(){
		cout<<"请输入10个数字排序"<<endl;
		for(int i=0;i<10;i++){
			cin>>a;
			list[a]++;
		}
	}
	void get(){
		for(int i=0;i<10000;i++){
			if(list[i]!=0){
				for(int j=0;j<list[i];j++){
					cout<<i<<" ";
				}	
			}
		}
	}	
};
int main(){
	t a;
	a.set();
	a.get();
	return 0;
}

  

posted @ 2024-01-28 11:07  fushuxuan1  阅读(7)  评论(0)    收藏  举报