快速排序的partition版本实现
int partition(int arr[], int low, int high) { int pivot = arr[high]; int i = low-1; for (int j = low; j < high; j++) { if(arr[j] <= pivot) { i++; swap(arr[i], arr[j]); } } swap(arr[i+1],arr[high]); return i+1; } void quickSort(int arr[], int low, int high) { if(low < high) { int mid = partition(arr, low, high); quickSort(arr, low, mid-1); quickSort(arr, mid+1, up); } }