1.
#include<iostream> #include<list> using namespace std; int main(){ list<int> a={1,2,3,4,5}; list<int> b={6,7,8,9,10}; list<int>::iterator i; a.splice(a.end(),b,b.begin(),b.end()); for(i=a.begin();i!=a.end();++i){ cout<<*i<<" "; } return 0; }
2.
#include<iostream> #include<list> using namespace std; int main(){ list<int> a={1,2,3}; list<int> b={4,5,6}; list<int>::iterator i,j; i=a.begin(); j=a.end(); advance(i,+2); b.splice(b.begin(),a,i,j); for(i=b.begin();i!=b.end();++i){ cout<<*i<<" "; } return 0; }
3.
#include<iostream> #include<list> using namespace std; int main(){ list<int> a={1,2,3,4,5}; list<int> b={6,7,8}; list<int>::iterator i,j; i=a.begin(); j=a.end(); advance(i,+1); advance(j,-1); b.splice(b.begin(),a,i,j); for(i=b.begin();i!=b.end();++i){ cout<<*i<<" "; } return 0; }
标签:std,容器,begin,main,end,迭代,list,include From: https://www.cnblogs.com/wangyueshuo/p/17947971