Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int a[10000];
  8. int b;
  9. cin >> b;
  10. for (int i=0; i<b; i++)
  11. {
  12. cin >> a[i];
  13. }
  14. for (int i=1; i<b; i++)
  15. {
  16. for (int j=0; j<b-i; j++)
  17. {
  18. if (a[j]>a[j+1])
  19. {
  20. int temp=a[j];
  21. a[j]=a[j+1];
  22. a[j+1]=temp;
  23. }
  24. }
  25. }
  26. for (int i=0; i<b; i++)
  27. {
  28. cout << a[i] << " ";
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement