#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
void initVec()
{
vector<int> vec1(4);
cout<<"Vec1 size = "<<vec1.size()<<endl;
for(int a = 0;a<vec1.size();a++)
{
cout<<vec1.at(a)<<endl;;
}
vector<int> vec2(2,3);
cout<<"Vec2 size = "<<vec2.size()<<endl;
for(int a1 = 0;a1<vec2.size();a1++)
{
cout<<vec2.at(a1)<<endl;
}
int array[5] = {1,2,3,4,5};
vector<int> vec3(array,array+5);
cout<<"vec3 size = "<<vec3.size()<<endl;
for(int a2 = 0;a2<vec3.size();a2++)
{
cout<<vec3.at(a2)<<endl;
}
}
void operVec()
{
int array[5] = {1,2,3,4,5};
vector<int> vec(array,array+5);
cout<<"The original vec:"<<endl;
for(int i =0;i<vec.size();i++)
{
cout<<vec.at(i)<<endl;
}
vector<int>::iterator ii= vec.begin();
for(;ii != vec.end();ii++)
{
cout<<*ii<<endl;
}
vec.push_back(6);
cout<<"After push_bak:"<<endl;
for(int i2 =0;i2<vec.size();i2++)
{
cout<<vec.at(i2)<<endl;
}
vector<int>::iterator iii= vec.begin();
vec.insert(iii,3,5);
cout<<"After insert:"<<endl;
for(int i3 =0;i3<vec.size();i3++)
{
cout<<vec.at(i3)<<endl;
}
//***************************
vec.pop_back();
cout<<"After pop_back:"<<endl;
for(int i4 =0;i4<vec.size();i4++)
{
cout<<vec.at(i4)<<endl;
}
vector<int>::iterator iiii= vec.begin();
vec.erase(iiii,iiii+3);
cout<<"After erase:"<<endl;
for(int i5 =0;i5<vec.size();i5++)
{
cout<<vec.at(i5)<<endl;
}
}
int main()
{
//initVec();
operVec();
return 0;
}