不知道哪里出了问题,先记录一下,调试好了再提交
public class QuickSort {
public int swap(int a,int b) {
int tmp = a;
a = b;
b = tmp;
return a;
}
public int[] quickSort(int[] d, int first, int last) {
int lower = first + 1;
int upper = last;
swap(d[first],d[(first+last)/2]);
int bound = d[first];
while (lower <= upper) {
while (d[lower] < bound) {
lower++;
}
while (bound < d[upper]) {
upper--;
}
if (lower < upper) {
swap(d[lower++],d[upper--]);
} else {
lower++;
}
swap (d[upper],d[first]);
if (first < upper-1) {
quickSort(d,first,upper-1);
}
if (upper+1 < last) {
quickSort(d,upper + 1, last);
}
}
return d;
}
}