![]()
#include<stdio.h>
int Partition(int A[], int low, int high){
    int pivot;
    pivot = A[low];
    while(low < high){
        while(low < high && A[high] >= pivot)// 1.相等不替换 2.不要遗漏low < high的判断 
            high--;
        A[low] = A[high];
        while(low < high && A[low] <= pivot) 
            low++;
        A[high] = A[low];
    }
    A[low] =pivot;
    return low;
}
void Qsort(int A[], int low, int high){
    int pivot;
    if(low < high){//不要写成 while 导致死循环 
        pivot = Partition(A ,low, high);
        Qsort(A, low, pivot-1);
        Qsort(A, pivot+1, high);
    }
}
void QuickSort(int A[], int n){
    Qsort(A, 0, n-1);
}
int main(){
    int A[15]={5,6,4,3,2,6,4,4,6,5,3,22,6,1,-23};
    QuickSort(A, 15);
    for(int i=0; i<15; i++)
        printf("%d ", A[i]);
    return 0;
}
 
![]()