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