Advertisement
shawonrog

algorithm sorting 1st

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