Merge pull request #17 from theycallmemac/patch-6

Rename InsertionSort.c to Sorts/InsertionSort.c
This commit is contained in:
Rohit Gupta 2017-08-08 13:47:15 +05:30 committed by GitHub
commit 6d67344649

29
Sorts/InsertionSort.c Normal file
View File

@ -0,0 +1,29 @@
#include <stdio.h>
#incude <stdlib.h>
#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;
}