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 wypisz() {
  8. for (int i=0; i < N; i ++)
  9. cout << tab[i] << " ";
  10. cout << endl;
  11.  
  12. }
  13. void wstawienie(int x) {
  14. int j = N - 2;
  15. while ( x < tab[j]){
  16. swap(tab[j + 1], tab[j]);
  17. j--;
  18. if (j == -1)break;
  19. }
  20. tab [j + 1] = x;
  21. }
  22. int main() {
  23. wypisz();
  24. wstawienie(10);
  25. wypisz();
  26. return 0;
  27. }
  28.  
  29.  
  30.  
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
6 13 15 19 22 0 
6 10 13 15 19 22