fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. int main ()
  7. {
  8. vector <int> v (5, -1);
  9. vector <int> :: iterator itr=v.begin();
  10.  
  11. const unsigned size = v.size() ;
  12. for (unsigned i=0; i < size; ++i)
  13. itr = v.insert(itr, i) + 2 ;
  14.  
  15. for ( auto e : v )
  16. cout << setw(2) << e << '\n' ;
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
 0
-1
 1
-1
 2
-1
 3
-1
 4
-1