#include <iostream>
using namespace std;
void print(int array[],int beg,int end){
for(int i=beg;i<=end;i++)
printf("%d ",array[i]);
printf("\n");
}
void quick_sort(int array[],int beg,int end){
int point=array[beg];
int left=beg+1;
int right=end;
int tmp;
if(left>=end)
return;
if(beg>=end)
return;
while(left<right){
while(array[right]>point)
--right;
while(array[left]<point){
++left;
if(left>=right){
left=right;
break;
}
}
if(left<right){
tmp=array[left];
array[left]=array[right];
array[right]=tmp;
++left;
--right;
}
}
array[beg]=array[left];
array[left]=point;
// print(array,beg,end);
// printf("******** %d %d ****** \n",beg,end);
quick_sort(array,beg,left);
quick_sort(array,right+1,end);
}
int main(){
int array[]={6,1,2,7,9,3,4,5,10,8};
int size=10;
quick_sort(array,0,size-1);
print(array,0,9);
return 0;
}