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