We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents bc32952 + 1553c03 commit 832c1e7Copy full SHA for 832c1e7
sortingAlgo/insertionSort/InsertionSort.c
@@ -0,0 +1,30 @@
1
+#include <stdio.h>
2
+
3
+void main()
4
+{
5
+ int n,array[1000],c,d,t;
6
7
+ printf("Enter number of elements\n");
8
+ scanf("%d", &n);
9
10
+ printf("Enter %dintegers\n",n);
11
12
+ for(c=0;c<n;c++)
13
+ scanf("%d",&array[c]);
14
15
+ for(c=1;c<=n-1;c++) {
16
+ d=c;
17
18
+ while(d>0 &&array[d-1]>array[d]) {
19
+ t = array[d];
20
+ array[d] = array[d-1];
21
+ array[d-1] = t;
22
+ d--;
23
+ }
24
25
+ printf("Sorted list in ascending order:\n");
26
+ for(c=0;c<n-1;c++){
27
+ printf("%d\n",array[c]);
28
29
+ getch();
30
+}
0 commit comments