#include <unistd.h>
#include <stdio.h>
using namespace std;
void quickSort(int arr[], int left, int right) {
if (left > right) {
return;
}
int i = left;
int j = right;
int base = arr[left];
while(i != j) {
while(arr[j] >= base && i<j) {
j--;
}
while(arr[i] <= base && i<j) {
i++;
}
if(i<j) {
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
}
arr[left] = arr[i];
arr[i] = base;
quickSort(arr, left, i-1);
quickSort(arr, i+1, right);
}
int main() {
printf("----------before--------\n");
int arr[] = {8,5,4,6,2,7,9,1,0,3};
for(int i=0; i<10; i++) {
printf("arr[%d]=%d\n", i, arr[i]);
}
quickSort(arr, 0, 9);
printf("--------after---------\n");
for(int k=0; k<10; k++) {
printf("arr[%d]=%d\n", k, arr[k]);
}
}