#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void quicksort_(int a[], int l, int r);
void quicksort(int a[], int n);
void quicksort_(int a[], int l, int r) {
int lp;
int rp;
int c;
int p;
int t;
while (l < r) {
lp = l;
rp = r;
c = ((rp - lp) >> 1) + lp;
t = a[c];
if (t < a[lp]) {
a[c] = a[lp];
a[lp] = t;
}
t = a[rp];
if (t < a[c]) {
a[rp] = a[c];
if (t < a[lp]) {
a[c] = a[lp];
a[lp] = t;
} else {
a[c] = t;
}
}
p = a[c];
lp++;
rp--;
while (lp <= rp) {
while (a[lp] < p) {
lp++;
}
while (p < a[rp]) {
rp--;
}
if (rp < lp) {
break;
}
t = a[lp];
a[lp] = a[rp];
a[rp] = t;
lp++;
rp--;
}
if (rp - l < r - lp) {
quicksort_(a, l, rp);
l = lp;
} else {
quicksort_(a, lp, r);
r = rp;
}
}
}
void quicksort(int a[], int n) {
quicksort_(a, 0, n - 1);
}
int main(void) {
FILE *fin;
char buf[256];
char *token;
int nums[10];
int i;
fin
= fopen("numbers.dat", "r");
for (i = 0; i < 10; i++) {
}
quicksort(nums, 10);
for (i = 0; i < 10; i++) {
}
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8c3RkbGliLmg+CiNpbmNsdWRlPHN0cmluZy5oPgoKdm9pZCBxdWlja3NvcnRfKGludCBhW10sIGludCBsLCBpbnQgcik7CnZvaWQgcXVpY2tzb3J0KGludCBhW10sIGludCBuKTsKCnZvaWQgcXVpY2tzb3J0XyhpbnQgYVtdLCBpbnQgbCwgaW50IHIpIHsKCWludCBscDsKCWludCBycDsKCWludCBjOwoJaW50IHA7CglpbnQgdDsKCQoJd2hpbGUgKGwgPCByKSB7CgkJbHAgPSBsOwoJCXJwID0gcjsKCQljID0gKChycCAtIGxwKSA+PiAxKSArIGxwOwoJCQoJCXQgPSBhW2NdOwoJCWlmICh0IDwgYVtscF0pIHsKCQkJYVtjXSA9IGFbbHBdOwoJCQlhW2xwXSA9IHQ7Cg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