fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int N=5;
  5. int tab[N] = {6, 3, 15, 9, 2};
  6. void babelek() {
  7. for (int i = 0; i < N - 1 ; i++)
  8. if (tab[i] > tab[i + 1]) swap(tab[i], tab [i + 1]);
  9. }
  10.  
  11. void wypisz() {
  12. for (int i=0; i<N; i++)
  13. cout<<tab[i]<<" ";
  14. cout<<endl;
  15. }
  16.  
  17. void sort_b() {
  18. for (int j=0; j<N-1; j++)
  19. babelek();
  20. }
  21.  
  22. int main() {
  23. // sprawdź działanie funkcji
  24. sort_b();
  25. wypisz();
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
2 3 6 9 15