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