public static int partition(int[] a, int f, int b) { int pivot = a[f]; while (f < b) { while (f < b && a[b] >= pivot) { b--; } while (f < b && a[f] < pivot) { f++; } if (f < b) { int tmpB = a[b]; a[b] = a[f]; a[f] = tmpB; } } return b; } public static void quickSort(int[] a, int f, int b) { if (f < b) { int division = partition(a, f, b); quickSort(a, f, division); quickSort(a, division + 1, b); } }
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/10430.html