Asked by
AL MaMun (4 Golds)
Friday, 31 Jul 2020, 04:49 PM
at (Education
Tutorials)
|
|
|
|
Insertion sort C program : #include<stdio.h> int main() { int a[100], i, j, k, n; scanf("%d", &n); for(i=0; i<n; i++) scanf("%d", &a[i]); for(i=0; i<n; i++) printf("%d ", a[i]); printf("\n\n"); for(j=1; j<n; j++) { for(i=0; i<n; i++) { k = a[i]; if(a[i]>a[j]) { a[i]=a[j]; a[j]=k; } } } for(i=0; i<n; i++) printf("%d ", a[i]); } |