Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int i, j, pom;
  8. int tab [10];
  9. cout << "Podaj elementy tablicy do sortowania" << endl;
  10. for (i = 1; i <= 10; i++)
  11. {
  12. cout << "Element nr " << i << " = ";
  13. cin >> tab [i];
  14. }
  15. for (j = 10; j > 1; j--)
  16. for (i = 1; i<= j; i++)
  17. if (tab [i] > tab [i+1])
  18. {
  19. pom = tab [i];
  20. tab [i] = tab [i+1];
  21. tab [i+1] = pom;
  22. }
  23. cout << endl << "Oto zawartosc tablicy po posortowaniu:" <<endl;
  24. for (i=1; i<=10; i++) cout << tab [i] << " ";
  25. cout << endl;
  26. system ("pause");
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement