Skip to main content

Test cases

Task 1 

 section [krok4] of the 9.3.3

 Task 2

 

Source code of the test program:

include <stdio.h>

void insertSort(int a[], int length) {

int i, j, value;
for (i = 1; i < length; ++i) {

value = a[i];
for (j = i - 1; j >= 0 && a[j] > value; --j) {

a[j + 1] = a[j];
}

a[j + 1] = value;

}

}
int main() {

int a[9]={5,3, 1, 2,7,9,4,6,8};
int i;
for(i=0; i< 9; i++){

printf("%d", a[i]);

}
printf("\n");
insertSort(a,9);
for(i=0; i< 9; i++){

printf("%d", a[i]);

}
return 0;

}

}