#include #include using namespace std; /* Bubble sorts an array. T must have > operator and there must be a * function void swap (T &, T&) that swaps two instances of T. */ template void BubbleSortArray(T * array, int count) { int i, j; bool stillSwapping=true; // j is the index of the first element of the part that is already sorted for (j=count; stillSwapping; j--) { stillSwapping=false; for (i=0; iarray[i+1]) { // swap if out of order swap (array[i], array[i+1]); stillSwapping=true; } } } } /* Prints an array in the following format: first the number of elements * in the array, then colon, then comma-separated, the elements themselves, * then newline. There must be a function * istream &operator<<(ostream &, const T &) * defined. */ template void PrintArray(const T * array, int count) { int i; cout << count << ": "; for (i = 0; i < count; i++) { if (i!=0) cout << ", "; cout << array[i]; } cout<>(istream &, T &) * defined. */ template bool InputArray(T *& array, int & count) { int i; cin >> count; array = new (nothrow) T[count]; if (array == NULL) return false; for (i=0; i> array[i]; return true; }