Posted on 2011-04-27 02:54
S.l.e!ep.¢% 阅读(4189)
评论(0) 编辑 收藏 引用 所属分类:
C++
如何合并两个vector? merge 收藏
view plaincopy to clipboardprint?
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
vector<string> vec1, vec2;
vec1.push_back("aa");
vec1.push_back("bb");
vec1.push_back("cc");
vec2.push_back("dd");
vec2.push_back("ee");
vec2.push_back("ff");
vector<string> vec(vec1.size() + vec2.size());
merge(vec1.begin(), vec1.end(), vec2.begin(), vec2.end(), vec.begin());
for (int j = 0; j < vec.size(); ++j) {
cout << vec[j] << endl;
}
}
http://blog.csdn.net/made_in_chn/archive/2009/08/04/4408756.aspx
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/Augusdi/archive/2010/04/09/5466729.aspx