#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;
void print(vector<int> v)
{
for(vector<int>::iterator it=v.begin();it!=v.end();it++)
cout<<*it<<" ";
cout<<endl;
}
void test01()
{
int arr[]={1,5,6,5,5,6,2,8,9};
vector<int>v1(arr,arr+sizeof(arr)/sizeof(int));
vector<int>v2;
print(v2);
vector<int>v3(20,1);
print(v3);
}
void test02()
{ int arr[]={1,5,6,5,5,6,2,8,9};
vector<int>v1(arr,arr+sizeof(arr)/sizeof(int));
v1.insert(v1.begin()+3,100);
print(v1);
v1.insert(v1.begin()+6,5,200);
print(v1);
v1.insert(v1.begin()+2,v1.begin ()+4,v1.begin()+8);
print(v1);
}
void test03()
{ int arr[]={1,5,6,5,5,6,2,8,9};
vector<int>v1(arr,arr+sizeof(arr)/sizeof(int));
v1.erase(v1.begin()+2,v1.begin ()+4);
print(v1);
v1.erase (v1.begin());
print(v1);
}
void test04()
{
int arr[]={1,5,6,5,5,6,2,8,9};
vector<int>v1(arr,arr+sizeof(arr)/sizeof(int));
vector<int>v2;
v2=v1;
print(v2);
}
void test05()
{
int arr[]={1,5,6,5,5,6,2,8,9};
vector<int>v1(arr,arr+sizeof(arr)/sizeof(int));
cout<<"front: "<<v1.front()<<endl;
cout<<"back: "<<v1.back()<<endl;
}
void test06()
{
int arr[]={1,5,6,5,5,6,2,8,9};
vector<int>v1(arr,arr+sizeof(arr)/sizeof(int));
if(v1.empty())
cout<<"kong!";
else
cout<<v1.size()<<endl;
}
void test07()
{
int arr[]={1,5,6,5,5,6,2,8,9};
vector<int>v1(arr,arr+sizeof(arr)/sizeof(int));
v1.clear();
print(v1);
for(int i=1;i<=10000;i++)
v1.push_back(i);
cout<<"size: "<<v1.size()<<endl;
cout<<"capacity: "<<v1.capacity()<<endl;
}
void test08()
{
int arr[]={1,5,6,5,5,6,2,8,9};
vector<int>v1(arr,arr+sizeof(arr)/sizeof(int));
print(v1);
v1.resize(3);
print(v1);
v1.resize(8);
print(v1);
v1.resize(10,1);
print(v1);
}
void test09()
{
int arr[]={1,5,6,5,5,6,2,8,9};
vector<int>v1(arr,arr+sizeof(arr)/sizeof(int));
int arr1[]={10,10,10,10,10,10};
vector<int>v2(arr1,arr1+sizeof(arr1)/sizeof(int));
print(v1);
print(v2);
v1.swap(v2);
print(v1);
print(v2);
}
int main()
{
test01();
return 0;
}