VECTOR INSERT()

复制代码
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    vector<int> a(20);
    a.push_back(1);
    int arr[]={1,2,3,4,5};
    vector<int> b(arr,arr+sizeof(arr)/sizeof(int));
    int ar[]={7,8,9,10,11};
    vector<int> c(ar,ar+sizeof(ar)/sizeof(int));
    b.insert(b.begin(),c.begin(),c.end());
    cout<<b[2];
    return 0;
}

格式 说明
insert(pos,e) 在pos位置之前插入新元素e
insert(pos,n,e) 在pos位置之前插入n个元素e
insert(pos,first,last) 在pos位置之前,插入其他容器位于[fist,last]区域的所有元素

 
复制代码

 

posted @   hanxuyao  阅读(7)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
点击右上角即可分享
微信分享提示