Vector-Erase

  • + 0 comments

    Earasing the vectors using the C++ language

    Code solution :

    include

    include

    include

    include

    include

    using namespace std;

    int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ vectorv; int n,x; cin>>n; for(int i = 0; i>x; v.push_back(x); } int y; cin>>y; v.erase(v.begin()+y-1); int z,a; cin>>z>>a; v.erase(v.begin()+(z-1), v.begin()+(a-1));

    cout<<v.size()<<endl;
    for (int i = 0; i<v.size(); i++) {
        cout<<v[i]<<" ";
    }
    return 0;
    

    }