update quick sort

This commit is contained in:
cinita 2019-01-10 00:43:52 +08:00
parent b9749985c0
commit fc8635016c

View File

@ -24,10 +24,13 @@ public class QuickSort {
int i = p;
for(int j = p; j < r; ++j) {
if (a[j] < pivot) {
int tmp = a[i];
a[i] = a[j];
a[j] = tmp;
++i;
if (i == j) {
++i;
} else {
int tmp = a[i];
a[i++] = a[j];
a[j] = tmp;
}
}
}