fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void sort_b(int tab[], int n) {
  5. for (int i = 0; i < n - 1; i++)
  6. for (int j = 0; j < n - 1 - i; j++)
  7. if (tab[j] > tab[j + 1])
  8. swap(tab[j], tab[j + 1]);
  9. }
  10.  
  11. int main() {
  12. int tab[] = {6, 3, 15, 9, 2};
  13.  
  14. cout << "Przed: ";
  15. for (int x : tab) cout << x << " ";
  16.  
  17. sort_b(tab, 5);
  18.  
  19. cout << "\nPo: ";
  20. for (int x : tab) cout << x << " ";
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
Przed: 6 3 15 9 2 
Po: 2 3 6 9 15