/////// File: intsort.C /////// // applying arbitrary quick sort #include #include "arbqsort.h" int cmp_bigger(int x[], int i, int j) { return ( x[i] - x[j] ); } int cmp_smaller(int x[], int i, int j) { return ( x[j] - x[i] ); } void intswitch(int *a, int i, int j) { int s; s = a[i]; a[i] = a[j]; a[j] = s; } int main() { int a[] = {5,3,-1, 9 , 22, 99}; int b[] = {5,3,-1, 9 , 22, 99}; quicksort(a,0,5, CMP_FN(cmp_bigger), SWAP_FN(intswitch)); quicksort(b,0,5, CMP_FN(cmp_smaller), SWAP_FN(intswitch)); cout << a[0] << ' ' << a[1] << ' ' << a[2] << ' ' << a[3] << ' ' << a[4] << ' ' << a[5] << "\n"; cout << b[0] << ' ' << b[1] << ' ' << b[2] << ' ' << b[3] << ' ' << b[4] << ' ' << b[5] << "\n"; return(0); }