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