#include <bits/stdc++.h> using namespace std; int main() { list <int> a = {1,2,3,4,5}; list <int> b = {6,7,8,9,10}; a.splice(a.end(),b,b.begin(),b.end()); list <int> ::iterator i; for (i = a.begin();i != a.end(); i++) cout << *i << " " ; return 0; } #include <bits/stdc++.h> using namespace std; int main() { list <int> a = {4,5,6}; list <int> b = {1,2,3}; list <int> ::iterator x; list <int> ::iterator y; x=b.begin(); y=b.end(); advance(x,+2); a.splice(a.begin(),b,x,y); list <int> ::iterator i; for (i = a.begin();i != a.end(); i++) cout << *i << " " ; return 0; } #include <bits/stdc++.h> using namespace std; int main() { list <int> a = {4,5,6}; list <int> b = {1,2,3}; list <int> ::iterator x; list <int> ::iterator y; x=b.begin(); y=b.end(); advance(x,+2); a.splice(a.begin(),b,x,y); list <int> ::iterator i; for (i = a.begin();i != a.end(); i++) cout << *i << " " ; return 0; }
标签:std,advance,begin,end,iterator,list From: https://www.cnblogs.com/hanxuyao/p/17947975