#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 insertionSort(int array[], int size) { int startScan, minIndex, minValue; for (int i1 = 1; i1 < size ; i1++) { int currentValue = array[i1] ; int j1=0 ; for( j1=i1 ; j1 > 0 ; j1-- ) { if( currentValue < array[j1-1] ) { //shift array[j1] = array[j1-1]; } else { //found the right position break ; } } //for array[j1] = currentValue ; showArray( array , size ) ; } //for } int main() { int arr1[] = { 4 , 3 , 2 , 1 } ; showArray( arr1 , 4 ) ; insertionSort( arr1, 4 ) ; showArray( arr1 , 4 ) ; return ( 0 ) ; }