2 !!DESCRIPTION!! simple quicksort, tests recursion
3 !!ORIGIN!! LCC 4.1 Testsuite
4 !!LICENCE!! own, freely distributeable for non-profit. read CPYRIGHT.LCC
10 int in[] = {10, 32, -1, 567, 3, 18, 1, -51, 789, 0};
13 /* exchange - exchange *x and *y */
14 exchange(int *x,int *y) {
17 printf("exchange(%d,%d)\n", x - xx, y - xx);
18 t = *x; *x = *y; *y = t;
21 /* partition - partition a[i..j] */
22 int partition(int a[], int i, int j) {
29 i++; while (a[i] < v) i++;
30 j--; while (a[j] > v) j--;
31 if (i < j) exchange(&a[i], &a[j]);
33 exchange(&a[k], &a[j]);
37 /* quick - quicksort a[lb..ub] */
38 void quick(int a[], int lb, int ub) {
43 k = partition(a, lb, ub);
48 /* sort - sort a[0..n-1] into increasing order */
49 sort(int a[], int n) {
50 quick(xx = a, 0, --n);
53 /* putd - output decimal number */
67 sort(in, (sizeof in)/(sizeof in[0]));
68 for (i = 0; i < (sizeof in)/(sizeof in[0]); i++) {