桶排序
#include<iostream> using namespace std; int main(){ int value; int a,max=100000; int list[max]={0}; cin>>a; for(int i=0;i<a;i++){ cin>>value; list[value]++; } for(int i=0;i<max;i++){ for(int j=0;j<list[i];j++){ cout<<i<<" "; } } }
桶排序&类
#include <iostream> #include "Tong.h" using namespace std; int main(){ int a; cin>>a; tong t1; t1.get(a); }
class tong{ private: int value; int max=100000; int list[100000]={0}; public: get(int m){ for(int i=0;i<m;i++){ std::cin>>value; list[value]++; } for(int i=0;i<max;i++){ for(int j=0;j<list[i];j++){ std::cout<<i<<" "; } } } };
标签:include,int,max,代码,list,value,示范,排序 From: https://www.cnblogs.com/wangyueshuo/p/17992548