fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int N=5;
  5. int tab[N] = {16, 5, 12, 3, 12};
  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.  
  18. void sort_b() {
  19. for (int j=0; j<N-1; j++)
  20. babelek();
  21. }
  22.  
  23. int main() {
  24.  
  25. sort_b();
  26. wypisz();
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
3  5  12  12  16