Method One: First from right to left than base small number, and then from left to right to find than base of the number, and finally is smaller than the base of the number on the left, than the base size of the number on the right.
void qsort (int *a, int l, int r) {
if (l<r) {
int i=l;
int j=r;
int base=a[l];
int tmp;
while (I<J) {while
(I<j&&base<=a[j]) {
j--;
}
while (I<j&&base>=a[i]) {
i++
}
if (i<j) {
tmp=a[j];
A[j]=a[i];
A[i]=tmp
}
}
A[l]=a[i];
A[i]=base;
Qsort (a,l,i-1);
Qsort (a,i+1,r);
}
Method Two: From left to right to traverse, divided into less than region-equal region-greater than the region, and then recursively less than the region and greater than the region
void swap (int arr[],int i, int j) {
int tmp = arr[i];
Arr[i] = arr[j];
ARR[J] = tmp;
}
void partition (int a[],int l, int r,int *lef,int *rgt) {
int less=l-1;
int more=r;
while (L<more) {
if (A[l]<a[r]) {
swap (a,++less,l++);
} else if (A[l]>a[r]) {
swap (a,--more,l);
else{
l++
}
}
Swap (a,more,r);
*lef=less+1;
*rgt=more;
}
void quicksort (int a[],int l,int r) {
if (l<r) {
int lef,rgt;
Partition (A,L,R,&LEF,&RGT);
Quicksort (a,l,lef-1);
Quicksort (a,rgt+1,r);
}