垃圾基数排序

真的很垃圾啊

class cmp{
	int base;
	public:
	cmp(int pos=0):base(pos){}
	bool operator() (const int &a,const int & b){
		return (a/(int)pow(10,base))%10<(b/(int)pow(10,base))%10;
	}
};
int main(){
	int a[10];
	for(auto& x:a){
		x=rand();
	}
	for(int i=0;i<10;++i){
		sort(a,a+10,cmp(i));
		for(auto&x:a){
			cout<<x<<' ';
		}
		cout<<endl;
	}
	return 0;
}

  

posted @ 2018-08-07 15:20  kraylas  阅读(125)  评论(0编辑  收藏  举报