Program
#include
#include
#include
using namespace std;
void display(vector
{
for(int i=0;i<> v;
cout << "Initial size =" << i="0;i<5;i++)">> x;
v.push_back(x);
}
cout << "size after adding 5 values:"; cout << nsize =" << v.size() << ">::iterator itr=v.begin();
itr=itr+3;
v.insert(itr,1,9);
cout << "\n contents after inserting\n"; display(v); v.erase(v.begin()+3,v.begin()+5); cout << "contents after deletion:\n"; display(v); cout << "end\n"; return 0; } Output
Initial size =0
Enter five integer values:
1
2
3
4
5
size after adding 5 values:5
current contents:
1 2 3 4 5
size =6
contents now
1 2 3 4 5 6
contents after inserting
1 2 3 9 4 5 6
contents after deletion:
1 2 3 5 6
end
Press any key to continue