fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6. vector<int> v1 = {1,2,3,4,5};
  7.  
  8. // Remove single element (index 1)
  9. v1.erase(v1.begin() + 1);
  10.  
  11. // Erase range
  12. v1.erase(v1.begin() + 1, v1.begin() + 3);
  13.  
  14. for(int x : v1) cout << x << " ";
  15. }
  16.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
1 5