fork download
  1. #include <iostream>
  2. using namespace std;
  3. const int N=6;
  4. int tab[N]={6, 13, 15, 19, 22, 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]=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. wstawianie(14);
  23. wypisz();
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
6 13 14 15 19 22