fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6.  
  7. const int N=6;
  8.  
  9. int tab[N]={1,9,12,33,46,0};
  10.  
  11. void wstawianie(int x) {
  12.  
  13. int j = N - 2 ;
  14.  
  15. while (x< tab[j]) {
  16.  
  17. swap(tab[j+1],tab[j]);
  18.  
  19. j--;
  20.  
  21. if (j == -1) break;
  22.  
  23. }
  24.  
  25. tab[j+1]=x;
  26.  
  27. }
  28.  
  29. void wypisz() {
  30.  
  31. for (int i=0;i < N ; i++)
  32.  
  33. cout << tab[i]<< " ";
  34.  
  35. cout<<endl;
  36.  
  37. }
  38.  
  39.  
  40.  
  41. int main() {
  42.  
  43.  
  44.  
  45. wstawianie(57);
  46.  
  47. wypisz();
  48.  
  49. return 0;
  50.  
  51. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
1 9 12 33 46 57