fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6. vector<int> v1 = {1, 2, 4, 5};
  7. // Insert element 3 at index 2
  8. v1.insert(v1.begin() + 2, 3); // Output: 1 2 3 4 5
  9.  
  10. // Insert list of elements
  11. v1.insert(v1.begin() + 4, {4, 5}); // Output: 1 2 3 4 5 4 5
  12. return 0;
  13. }
  14.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty