#include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;
template<typename T>
class Print
{
public:
void operator()(T& t)
{
cout<<t<<" ";
}
};
int main()
{
int ary[5];
fill(ary,ary+5,1);
vector<int> v;
vector<int>::iterator It;
Print<int>print;
copy(ary,ary+5,back_inserter(v));
cout<<"vector v :";
for_each(v.begin(),v.end(),print);
cout<<endl;
It = v.begin();
cout<<"v.insert(It,5) :";
v.insert(It,5);
for_each(v.begin(),v.end(),print);
cout<<endl;
It = v.begin() + 5;
cout<<"v.insert(It,ary+2,ary+5) : ";
v.insert(It,ary+2,ary+5);
for_each(v.begin(),v.end(),print);
cout<<endl;
It = v.end()- 2;
cout<<"v.insert(It,2,20) :";
v.insert(It,2,20);
for_each(v.begin(),v.end(),print);
cout<<endl;
getchar();
return 0;
}