diff --git a/InsertionSort.c b/InsertionSort.c new file mode 100644 index 00000000..4f3e749e --- /dev/null +++ b/InsertionSort.c @@ -0,0 +1,29 @@ +#include +#incude +#define MAX 20 + + + +int main() +{ + int i, elmtToInsert , j , arraySort[MAX] = {0}; + + for(i = 1 ; i < MAX ; i++) + { + elmtToInsert = arraySort[i]; + j = i - 1 ; + + while( j >= 0 && elmtToInsert < arraySort[j]) + { + arraySort[j+1] = arraySort[j]; + j--; + } + + arraySort[j+1] = elmtToInsert ; + } + + + + + return EXIT_SUCCESS; +}