1、

http://bbs.csdn.net/topics/370029802

 #include <iostream>
#include <limits>
#include <assert.h>
#include <vector>
#include <algorithm>
#include <functional> // For greater<int>( ) using namespace std; int _tmain(int argc, _TCHAR* argv[])
{
std::vector<int> vRqt;
std::vector<int> vRsp;
std::vector<int> vAll;
//vAll.reserve(100);
vRqt.push_back();
vRqt.push_back();
vRqt.push_back();
vRqt.push_back();
sort(vRqt.begin(),vRqt.end());
vRsp.push_back();
vRsp.push_back();
vRsp.push_back();
vRsp.push_back();
vRsp.push_back();
sort(vRsp.begin(),vRsp.end());
merge(vRqt.begin(),vRqt.end(), vRsp.begin(),vRsp.end(), back_inserter(vAll)); //合并
sort(vAll.begin(),vAll.end());//排序
vAll.erase( unique( vAll.begin(), vAll.end() ), vAll.end());//擦出
copy(vAll.begin(),vAll.end(),ostream_iterator<int>(cout," "));//显示
return ;
}

ZC:注意 第29行 back_inserter() 和 第31行 unique() 的使用

2、

05-11 17:54