#include #include #include using namespace std; #if 0 int maxIndex(string *array, int size); void selectionSort(string *arrayIn, int sizeIn); int main() { // create array and initialize with values int size ; cout << "How many values do you want to enter? "; cin >> size; string* array = new string[size]; cout << "Enter a list of " << size << " values: " <> array[i]; // sort the array selectionSort(array, size); // display the array for (int j = 0; j < size; j++) cout << array[j] << ' '; cout << endl; return 0; } bool isBefore (string thing1, string thing2) { // basic ordering return thing1 < thing2; } int maxIndex(string *array, int size) { int maxIndex = 0; for (int i=1; i < size; i++) { if (isBefore(array[maxIndex],array[i]) ) { maxIndex = i; } } return maxIndex; } void swap (string &thing1, string &thing2) { string temp = thing1; thing1 = thing2; thing2 = temp; } void selectionSort(string *arrayIn, int sizeIn) { for(int size = sizeIn; size > 1; size--) { int k = maxIndex(arrayIn,size); swap(arrayIn[k], arrayIn[size-1]); } } #endif