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