insert()用法"/>
insert()用法
insert(it,x)前面是位置,后面是要插入的元素;
#include "stdafx.h"
#include<stdio.h>
#include<vector>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{vector<int> vi;for(int i=1;i<=5;i++){vi.push_back(i);}for(int i=1;i<=5;i++){vi.insert(vi.begin()+2,i+5);}vector<int>::iterator it=vi.begin();for(;it!=vi.end();it++){printf("%d ",*it);}
}
更多推荐
insert()用法
发布评论