1234567891011121314151617181920212223242526272829
void insertSort(int A[], int size) { int j = 0; int temp = 0; //SORT ARRAY for (int i = 0; i < size; ++i) { j = i + 1; while(j > 0 && A[j] < A[j-1]) { temp = A[j]; A[j] = A[j-1]; A[j-1] = temp; j--; } } //PRINT SORTED ARRAY for (int i = 0; i < size; ++i) { cout << A[i] << " "; } cout << "\n"; }