vector用法详细介绍见链接
C++ vector用法的详细学习_IT.Husky的博客-CSDN博客
示例
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<int> a{ 1,3,5,7,9 };
vector<int> b{ 0,4,8,2,5 };
vector<int> c{ 1,6,7,3,8 };
vector<int> hebing;
hebing.insert(hebing.end(), a.begin(),a.end());//数据合并
hebing.insert(hebing.end(), b.begin(), b.end());
hebing.insert(hebing.end(), c.begin(), c.end());
sort(hebing.begin(), hebing.end());//升序排序
vector<int>::iterator iter = unique(hebing.begin(), hebing.end());//遍历查找重复项
hebing.erase(iter, hebing.end());//删除重复项
cout << "abc合并&&删除重复项后的size = " << hebing.size() << endl;
if (hebing.size() > 0)
{
cout << "分别为:" << endl;
for (int i = 0; i < hebing.size(); i++)
{
cout << hebing[i] << endl;
}
}
system("pause");
return 0;
}