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. void wypisz() {
  16. for (int i=0;i < N ; i++)
  17. cout << tab[i]<< " ";
  18. cout<<endl;
  19. }
  20.  
  21. int main() {
  22.  
  23. wstawianie(57);
  24. wypisz();
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
1 9 12 33 46 57