package com.keafmd.Sequence; /** * Keafmd * * @ClassName: QuickSort * @Description: 快速排序 * @author: 牛哄哄的柯南 * @date: 2021-06-24 10:32 */ public class QuickSort { //快速排序 public static void quickSort(int[] arr) { quickSort(arr, true); } public static void quickSort(int[] arr, boolean ascending) { if (ascending) { quickSort(arr, 0, arr.length - 1, true); } else { quickSort(arr, 0, arr.length - 1, false); } } public static void quickSort(int[] arr, int begin, int end, boolean ascending) { if (ascending) quickSort(arr, begin, end); else quickSortDescending(arr, begin, end); } //快排序升序 -- 默认 public static void quickSort(int[] arr, int begin, int end) { if (begin > end) { //结束条件 return; } int base = arr[begin]; int i = begin, j = end; while (i = base && i end) { //结束条件 return; } int base = arr[begin]; int i = begin, j = end; while (i = base && i