#include "stdio.h"
void sort(int left,int right,int array[]);
void main(){
//int a[]={6,4,2,7,4,9,6,10,6,9,3,5,1,89,12,34,1,4,6,97,56,34,65,8};
int a[]={12,8,18,1,8,8,10};
sort(0,6,a);
for(int i=0;i<7;i++){
printf("%d ",a[i]);
}
}
void sort(int left,int right,int array[]){
int l=left;
int r=right;
int pivor= array[(left+right)/2];
int temp=0;
while(l<r){
while(array[l]<pivor) l++;
while(array[r]>pivor) r--;
// printf("r = %d \n",r);
// printf("l = %d \n",l);
if(l>=r) break;
temp = array[l];
array[l]=array[r];
array[r]=temp;
if(array[l] == pivor) --r;
if(array[r] == pivor) ++l;
}
if(l == r){
l++;
r--;
}
printf("zui gou r = %d \n",r);
printf("zui huo l = %d \n",l);
if(left < r)
sort(left, r, array);
if(right > l)
sort(l, right, array);
}