Advertisement
Guest User

bal

a guest
Jul 20th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include<stdio.h>
  2. void insertionSort(int a[])
  3. {
  4. int i, j;
  5. for(i=1; i<10; i++)
  6. {
  7. for(j=i; j>=0; j--)
  8. {
  9. int temp;
  10. if(a[j-1]>a[j] && j-1>=0)
  11. {
  12. temp = a[j-1];
  13. a[j-1]=a[j];
  14. a[j]=temp;
  15. }
  16. }
  17. }
  18. }
  19.  
  20. int main()
  21. {
  22. int i, a[] = {10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  23. insertionSort(a);
  24. for(i =0; i<10; i++)printf("%d ", a[i]);
  25. printf("\n");
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement