advance

复制代码
#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;
}
复制代码

 

posted @   hanxuyao  阅读(26)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
点击右上角即可分享
微信分享提示