list

发布时间 2024-01-05 19:50:00作者: 郭立恒
//#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;
//    j = a.end();
//    advance(j,-1);
//    b.splice(b.begin(),a,j);
//    for(i = b.begin();i!=b.end();i++){
//        cout<<*i<<" ";
//    }
//    return 0;
//}
//
//#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;
//    j = a.end();
//    advance(j,-1);
//    b.splice(b.begin(),a,j);
//    for(i = b.begin();i!=b.end();i++){
//        cout<<*i<<" ";
//    }
//    return 0;
//}

#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;
}