#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
void print(vector <int>&v);
void main()
{
vector <int>v;
v.insert(v.begin(),8);
print(v);
int ary[3]={1,2,3};
fill(ary,ary+2,9);
v.insert(v.end(),ary+1,ary+3);
print(v);
vector<int>::iterator it=v.end();
v.insert(it,ary+1,ary+2);
print(v);
it=v.end();
v.insert(it-1,2,75);
print(v);
system("pause");
}
template<class T>
class Show
{
public:
void operator() (T&t){cout<<t<<" ";}
};
void print(vector<int>&v)
{
cout<<"vector v:"<<"\t";
Show<int>myshow;
for_each(v.begin(),v.end(),myshow);
cout<<endl;
cout<<"v.size():\t"<<v.size()<<endl;
cout<<"v.capacity():\t"<<v.capacity();
cout<<"\n\n";
}
#include<vector>
#include<algorithm>
using namespace std;
void print(vector <int>&v);
void main()
{
vector <int>v;
v.insert(v.begin(),8);
print(v);
int ary[3]={1,2,3};
fill(ary,ary+2,9);
v.insert(v.end(),ary+1,ary+3);
print(v);
vector<int>::iterator it=v.end();
v.insert(it,ary+1,ary+2);
print(v);
it=v.end();
v.insert(it-1,2,75);
print(v);
system("pause");
}
template<class T>
class Show
{
public:
void operator() (T&t){cout<<t<<" ";}
};
void print(vector<int>&v)
{
cout<<"vector v:"<<"\t";
Show<int>myshow;
for_each(v.begin(),v.end(),myshow);
cout<<endl;
cout<<"v.size():\t"<<v.size()<<endl;
cout<<"v.capacity():\t"<<v.capacity();
cout<<"\n\n";
}