int Partion(int asy[],int begin,int end) { int k=begin; int key=asy[end]; for(int i=begin;i<=end;++i) { if(asy[i]>key) { int temp=asy[k]; asy[k]=asy[i]; asy[i]=temp; k++; } } int temp=asy[k]; asy[k]=asy[end]; asy[end]=temp; return k; } void QuickSort(int asy[],int begin,int end) { if(begin<end) { int k=Partion(asy,begin,end); QuickSort(asy,begin,k-1); QuickSort(asy,k+1,end); } }
int asy[]={1,3,5,78,0,4,8,2,46,8,9,23}; int size=sizeof(asy)/sizeof(int); QuickSort(asy,0,size-1); for(int i=0;i<size;++i) { std::cout<<asy[i]<<" "; } std::cout<<endl;