快排模板

novice 刷题 2023-07-28 10:22:19 6

void kp(int l, int r) { int i, j, mid, tmp; i = l; j = r; mid = a[(i + j) /2]; while (i <= j) { while (a[i] < mid) i++; while (a[j] > mid) j--; if (i <= j) { tmp = a[i]; a[i] = a[j]; a[j] = tmp; i++; j--; } } if (l < j) kp(l, j); if (i < r) kp(i, r); }

{{ vote && vote.total.up }}

共 3 条回复

CPP 刷题王

欧克,我看不懂(太高级了

wczzq 原神启动

OK

Joshua Microsoft

知道了!