public static void quickSort(int a[], int l, int r) { if (l >= r) return; int i = l, j = r; int key = a[l]; while (i < j) { while (i < j && a[j] >= key) j--; if (i < j) a[i++] = a[j]; while (i < j && a[i] <= key) i++; if (i < j) a[j--] = a[i]; } a[i] = key; quickSort(a, l, i - 1); quickSort(a, i + 1, r); }
时间: 2024-12-22 08:28:11