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