#ifndef PRINT_H
#define PRINT_H
template<typename T>
void print(T b,T e)
{
while(b!=e)
cout<<*b++<<' ';
cout<<endl;
}
#endif
#include<iostream>
using namespace std;
#include<deque>
#include<vector>
#include"print.h"
#include<string>
int main()
{
int a[5]={33,22,11,55,44};
vector<int>vi(a,a+5);
cout<<vi.size()<<endl;
sort(vi.begin(),vi.end());
vector<int>::iterator b=vi.begin();
while(b!=vi.end())
{
cout<<*b++<<' ';
}
cout<<endl;
for(int i=0;i<5;i++)
cout<<a[i]<<endl;
cout<<endl;
print(vi.begin(),vi.end());
print(a,a+5);
print(vi.rbegin(),vi.rend());
vi.insert(++++vi.begin(),66);
print(vi.begin(),vi.end());
cout<<vi.size()<<'/'<<vi.max_size()<<endl;
vi.erase(------vi.end());
print(vi.begin(),vi.end());
vi.erase(++++vi.begin(),--vi.end());
print(vi.begin(),vi.end());
vector<int> v2(a,a+5);
print(v2.begin(),v2.end());
vi.swap(v2);
print(v2.begin(),v2.end());
print(vi.begin(),vi.end());
cout<<"*************************"<<endl;
swap(vi,v2);
print(v2.begin(),v2.end());
print(vi.begin(),vi.end());
cout<<"*************************"<<endl;
vector<int> t=vi;
vi=v2;
v2=t;
print(v2.begin(),v2.end());
print(vi.begin(),vi.end());
cout<<vi.size()<<endl;
}
![这里写图片描述](https://img-blog.csdn.net/20160324213046175)