intmain(){
vector<int> myvector;for(int i =0; i <100; i++)
myvector.push_back(i);
cout <<"size:"<<(int)myvector.size()<< endl;
cout <<"capacity:"<<(int)myvector.capacity()<< endl;
cout <<"max_size:"<<(int)myvector.max_size()<< endl;return0;}
intmain(){
vector<int> myvector;intsum(0);for(int i =1; i <=10; i++)
myvector.push_back(i);while(!myvector.empty()){
sum += myvector.back();
myvector.pop_back();}
cout <<"total:"<< sum << endl;return0;}
intmain(){
vector<int> myvector;for(int i =1; i <=10; i++)
myvector.push_back(i);for(int i =0; i < myvector.size(); i++)
cout << myvector[i]<<' ';
cout << endl;for(int i =0; i <3; i++)
myvector.pop_back();for(int i =0; i < myvector.size(); i++)
cout << myvector[i]<<' ';return0;}
intmain(){
vector<int> v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
v.push_back(4);for(auto e : v){
cout << e <<" ";}
cout << endl;
vector<int>::iterator pos =find(v.begin(), v.end(),2);if(pos != v.end()){
v.insert(pos,20);}for(auto e : v){
cout << e <<" ";}
cout << endl;
pos =find(v.begin(), v.end(),2);if(pos != v.end()){
v.erase(pos);}for(auto e : v){
cout << e <<" ";}
cout << endl;
v.erase(v.begin());for(auto e : v){
cout << e <<" ";}
cout << endl;return0;}
intmain(){
vector<int> myvector;for(int i =1; i <=10; i++)
myvector.push_back(i);//删除指定位置数据
myvector.erase(myvector.begin()+5);//删除指定一个位置,到另一个位置间的所有数据
myvector.erase(myvector.begin(), myvector.begin()+3);
cout <<"myvector contains:";for(unsigned i =0; i < myvector.size(); i++)
cout <<' '<< myvector[i];
cout << endl;return0;}
intmain(){
vector<int>foo(3,100);
vector<int>bar(5,200);
foo.swap(bar);
cout <<"foo contains:";for(unsigned i =0; i < foo.size(); i++)
cout <<' '<< foo[i];
cout << endl;
cout <<"bar contains:";for(unsigned i =0; i < bar.size(); i++)
cout <<' '<< bar[i];
cout << endl;return0;}