blob: 9f8e5b18a7549c257f2b3ab39b351369991ef1f4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
void quicksort(int lo, int hi, int base[])
{
int i,j;
int pivot,temp;
if (lo<hi) {
for (i=lo,j=hi,pivot=base[hi];i<j;) {
while (i<hi && base[i]<=pivot) i++;
while (j>lo && base[j]>=pivot) j--;
if (i<j) { temp=base[i]; base[i]=base[j]; base[j]=temp; }
}
temp=base[i]; base[i]=base[hi]; base[hi]=temp;
quicksort(lo,i-1,base); quicksort(i+1,hi,base);
}
}
|