Advertisement
Guest User

turbo sort

a guest
Oct 24th, 2014
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. //i had a[99999] earlier, even reducing array size didnt work, neither did allotting values to initialized variables(read somewhere)..
  2.  
  3. #include<stdio.h>
  4.  
  5. int main()
  6. {
  7. int m=0,t=0, a[15], i=0,j=0;
  8. scanf("%d", &t);
  9. for(i=0; i<t; ++i)
  10. {
  11. scanf("%d", &a[i]);
  12. }
  13.  
  14. for(i=0; i<t; ++i)
  15. {
  16. for(j=i+1; j<t; ++j)
  17. {
  18. if(a[i]>a[j])
  19. {
  20. m = a[i];
  21. a[i] = a[j];
  22. a[j] = m;
  23. }
  24. }
  25. }
  26.  
  27. for(i=0; i<t; ++i)
  28. {
  29. printf("%d\n", a[i]);
  30. }
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement