// // p.609 Selection sort // #include using namespace std; // prototypes void Swap(int&, int&); int MinIndex(int[], int, int); void SelectionSort(int[], int); int main() { int data[] = {126, 43, 26, 1, 113}; // call SelectionSort(data, 5); // output for(int i=0; i<5; i++) cout << data[i] << " "; cout << "\n\n"; return 0; } //--------------------------------------- void Swap(int& item1, int& item2) { int temp = item1; item1 = item2; item2 = temp; } //---------------------------------------- int MinIndex(int values[], int startIndex, int endIndex) { int indexOfMin = startIndex; for(int index = startIndex+1; index <= endIndex; index++) if( values[index] < values[indexOfMin]) indexOfMin = index; return indexOfMin; } //---------------------------------------- void SelectionSort(int values[], int numValues) { int endIndex = numValues - 1; for(int current=0; current