Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions IntroductionToAlgorithms/insertion-sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

int main()
{
int i;
int a[6]={31, 41, 59, 26, 41, 58};
for(i = 0; i < 6; i++) {
printf("%d\t",a[i]);
int i,n;
printf("Enter the Number of Elements\n");
scanf("%d",&n);
for(i = 0; i < n; i++) {
scanf("%d",a[i]);
}
printf("\n");

int key, j = 0;
for(j = 1; j < 6; j++) {
for(j = 1; j < n; j++) {
key = a[j];
i = j - 1;

Expand All @@ -22,7 +23,7 @@ int main()
}

printf("Sort Complete!\n");
for(i = 0; i < 6; i++) {
for(i = 0; i < n; i++) {
printf("%d\t", a[i]);
}
printf("\n");
Expand Down