fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. const int N=5;
  6.  
  7. int tab[N]={6, 3, 15, 9, 2};
  8.  
  9.  
  10.  
  11. void babelek() {
  12.  
  13. for (int i = 0; i < N - 1 ; i++)
  14.  
  15. if (tab[i] < tab[i + 1]) swap(tab[i], tab [i + 1]);
  16.  
  17. }
  18.  
  19.  
  20.  
  21.  
  22.  
  23. void wypisz() {
  24.  
  25. for (int i=0; i<N; i++)
  26.  
  27. cout<<tab[i]<<" ";
  28.  
  29. cout<<endl;
  30.  
  31. }
  32.  
  33.  
  34.  
  35.  
  36.  
  37. void sort_b() {
  38.  
  39. for (int j=0; j<N-1; j++)
  40.  
  41. babelek();
  42.  
  43. }
  44.  
  45.  
  46.  
  47.  
  48.  
  49. int main() {
  50.  
  51. // sprawdź działanie funkcji
  52.  
  53. sort_b();
  54.  
  55. wypisz();
  56.  
  57. return 0;
  58.  
  59. }
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
15 9 6 3 2