// Programmieren 1, Praktikum 4, Aufgabe 2 // Sven Eisenhauer // 08.12.2004 // // file: main.cpp // // purpose: Implementation of Selection Sort and Insertion Sort algorithm // #include using std::cout; using std::endl; #include using std::setprecision; using std::setw; // contains function prototypes for functions srand and rand #include #include void selectionSort(int[], int); void insertionSort(int[], int); int main () { const int arraySize=5; int array1[arraySize],array2[arraySize]; srand(time(0)); // fill the arrays with some random stuff for (int i=0;i= 0)) { // always copy the value from the array field before // so the gap "walks" to the left, until a[i] is at the right place // and we can put temp in it. a[i+1]=a[i]; i--; } // i+1 to compensate the last i--, because we want a[i] before the last i-- a[i+1]=temp; } } } // end function insertionSort