Advertisement
Eather

bubble sort (ascending)

Apr 15th, 2011
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. int main()
  5. {
  6.  
  7. int how;
  8.  
  9. scanf("%d",&how);
  10.  
  11. int arr[10];
  12. for(int i=0;i<how;i++)
  13. {
  14.   scanf("%d,",&arr[i]);
  15. }
  16.  
  17. for(int i=0;i<how;i++)
  18. for(int j=0;j<how;j++)
  19. if(arr[i]<arr[j])
  20. {
  21.   int temp;
  22.   temp=arr[i];arr[i]=arr[j];arr[j]=temp;
  23. }
  24.  
  25. for(int i=0;i<how;i++)printf("%d ",arr[i]);
  26.  
  27.  
  28.  
  29. return 0;
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement