void insertion_sort(int *a,int len)
{
int i,j,key;
for(i=1;i<len;i++){
key=a[i];
j=i-1;
while(j>=0 && a[j]>key){
a[j+1]=a[j];
j–;
}
a[j+1]=key;
}
}
int main(void)
{
int a[]={12,5,9,3,4,7,4,6,2},i;
for(i=0;i<9;i++)
printf("%d ",a[i]);
printf("n");
insertion_sort(a,9);
for(i=0;i<9;i++)
printf("%d ",a[i]);
printf("n");
return 0;
}