Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //C201050
- //AYAT ULLAH
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- vector<int> vec;
- int n,num;
- cout<<"Enter the vector size: "<<endl;
- cin>>n;
- for(int i=0;i<n;i++){
- cin>>num;
- vec.push_back(num);
- }
- for(auto x: vec) cout<<x<<" ";
- cout<<endl;
- vector<int>::iterator it;
- cout<<"Enter the position you want to erase: ";
- cin>>n;
- vec.erase(vec.begin()+n);
- cout<<"Enter the new number you want to insert :";
- cin>>num;
- vec.insert(vec.begin()+n,num);
- cout<<"New vector"<<endl;
- for(auto x: vec) cout<<x<<" ";
- return 0;
- }
Add Comment
Please, Sign In to add comment