乐趣区

关于java:java快排实现v20

        private static void quickSort(int[] array, int start, int end) {if (start < end) {
            int left = start, right = end;
//            以数组首元素作为【主元】int pivot = array[start];

            while (left < right) {
                do {if (array[right] < pivot) {array[left++] = array[right];
                        array[right] = pivot;
                        break;
                    } else {right--;}
                } while (right > left);

                while (left < right) {if (array[left] > pivot) {array[right--] = array[left];
                        array[left] = pivot;
                        break;
                    } else {left++;}
                }
            }

//            这里 left == right
            quickSort(array, start, left - 1);
            quickSort(array, right + 1, end);
        }
    }
退出移动版