代码
public static void quickSort(int[] arr, int start, int end) { //start和end以下标0开始为基准 if (start < end) { int k = partition(arr, start, end); quickSort(arr, start, k-1); quickSort(arr, k+1, end); } } public static int partition(int[] arr, int start, int end) { int temp = arr[start];//存起来 while(start < end) { while(start < end && arr[end] >= temp) end--; arr[start] = arr[end]; while(start < end && arr[start] <= temp) start++; arr[end] = arr[start]; } arr[start] = temp; return start; }