编辑代码

#include <stdio.h>

void quicksort(int left, int right, int a[]) {
    if (left > right) {
        return;
    }
    
    int i, j, pivot, temp, t;
    pivot = left;
    i = left;
    j = right;
    temp = a[pivot];
    
    while (i != j) {
        while (a[i] <= a[pivot] && i < j) {
            i++;
        }
        while (a[j] >= a[pivot] && i < j) {
            j--;
        }
        t = a[j];
        a[j] = a[i];
        a[i] = t;
    }
    
    a[pivot] = a[j];
    a[j] = temp;
    
    quicksort(left, j - 1, a);
    quicksort(j + 1, right, a);
}

int main() {
    int a[10] = {4, 7, 8, 1, 2, 3, 6, 9, 0, 0};
    int i;
    
    quicksort(0, 9, a);
    
    for (i = 0; i < 10; i++) {
        printf("%d ", a[i]);
    }
    
    return 0;
}