fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int N=6;
  5. int tab[N] = {1, 9, 12, 33, 46, 0};
  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]=x;
  14.  
  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(57);
  25. wypisz();
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
1 9 12 33 46 57