#include using namespace std ; //Selection Sort void showArray(const int array[], int size) { for (int count = 0; count < size; count++) cout << array[count] << " "; cout << endl; } void selectionSort(int array[], int size) { int startScan, minIndex, minValue; for (startScan = 0; startScan < (size - 1); startScan++) { minIndex = startScan; minValue = array[startScan]; for(int index = startScan + 1; index < size; index++) { if (array[index] < minValue) { minValue = array[index]; minIndex = index; } } array[minIndex] = array[startScan]; array[startScan] = minValue; showArray( array , 5 ) ; } } int main() { int arr1[] = { 5 , 4 , 3 , 2 , 1 } ; showArray( arr1 , 5 ) ; selectionSort( arr1, 5 ) ; showArray( arr1 , 5 ) ; return ( 0 ) ; }