fork download
  1. #include <vector>
  2. #include <string>
  3. #include <iostream>
  4. #include <deque>
  5. #include <list>
  6.  
  7. using std::cout;
  8. using std::cin;
  9. using std::cerr;
  10. using std::endl;
  11. using std::string;
  12. using std::vector;
  13. using std::list;
  14.  
  15. int main()
  16. {
  17. vector<int> ivec = { 5, 6, 7, 8, 9 };
  18.  
  19. double cnt = ivec.size() / 2.0;
  20.  
  21. int i = 0;
  22.  
  23. while (cnt > 0)
  24. {
  25. ivec.insert(ivec.begin(), i--);
  26. --cnt;
  27. }
  28.  
  29. for (auto &i : ivec)
  30. cout << i << " ";
  31.  
  32. cout << endl;
  33.  
  34. system("pause");
  35.  
  36. return 0;
  37. }
Success #stdin #stdout #stderr 0s 15240KB
stdin
Standard input is empty
stdout
-2 -1 0 5 6 7 8 9 
stderr
sh: 1: pause: not found