Advertisement
Guest User

Untitled

a guest
May 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int ins_search(int a[],int n)
  4. {
  5. int i,key,j;
  6. printf("Enter the search key\n");
  7. scanf("%d",&key);
  8. for(j=1;j<n;j++){
  9. key=a[j];
  10. i=j-1;
  11. while(i>0 && a[i]>key){
  12.  
  13. a[i+1]=a[i];
  14. i=i-1;
  15.  
  16. }
  17. a[i+1]=key;
  18.  
  19.  
  20. }
  21.  
  22. for(i=0;i<n;i++)
  23. {
  24. printf("%d",a[i]);
  25. }
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33. }
  34. int main()
  35. {
  36. int n,i,key,p;
  37. scanf("%d",&n);
  38. int a[n];
  39. for (i=0;i<n;i++)
  40. {
  41. scanf("%d",&a[i]);
  42. }
  43.  
  44. p=ins_search(a,n);
  45.  
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement