1 package iYou.neugle.sort; 2 3 public class Quick_sort { 4 public static void QuickSort(double[] array, int left, int right) { 5 if (left < right) { 6 int i = Division(array, left, right); 7 QuickSort(array, left, i - 1); 8 QuickSort(array, i + 1, right); 9 } 10 } 11 12 private static int Division(double[] array, int left, int right) { 13 double base = array[left]; 14 while (left < right) { 15 while (left < right && array[right] >= base) { 16 right--; 17 } 18 array[left] = array[right]; 19 while (left < right && array[left] <= base) { 20 left++; 21 } 22 array[right] = array[left]; 23 } 24 array[left] = base; 25 return left; 26 } 27 }
时间: 2024-12-21 15:04:02