Delete element 6 and the first three elements of the vector

-1
#include <iostream>
#include <vector>
#include <list>
using namespace std;
int main(){
    int i,n;
    vector <int> v(10);
    cout<<"ingrese 10 numeros"<<endl;
    for(i=0;i<10;i++){
        v[i]=i+1;
    }
    //necesito borrar el elemento 6
    v.erase(v.6)//segun el pofe sirve para borrar elemento indicado pero no me sirve 
    //y tambien los tres primeros elementos
    v.pop_front()//esta sirve para borrar el primer elemento pero no se como utilizarlo
    for(i=0;i<10;i++){
        cout<<v[i]<<"-";
    }
    return 0;
}
    
asked by Edwin Casco 06.04.2017 в 17:32
source

1 answer

0

I think that if you use it in the following way it will work, I do not know if there is one more correct, if so, I hope you correct me.

To delete the sixth element

v.erase(v.begin()+5);

For the first 3:

v.erase(v.begin(), v.begin()+3);

The function v.pop_front () if I'm not mistaken is for a list and not for the vector

    
answered by 06.04.2017 в 21:15