/* implements exchange sort. Each pass is given by a function. makes the code portable enough so that the bubble sort can be done by simply changing the function pass. */ #include const int NUM=10; void pass(int[], int); void print_array(int[]); void main(){ int a[NUM] = { 3, 7, 10, 1, 5, 0, 9, 12, 6, 4}; print_array(a); for (int i=NUM; i>=2; i--) pass(a,i); /* note once we do pass for i=2, we are done */ } void print_array(int b[]){ for (int i=0; imax_val){ max_val = b[j]; where_max = j; } b[where_max] = b[stop-1]; b[stop-1] = max_val; /* the slot we want is stop - 1, not stop */ print_array(b); }