#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <set>
using namespace std;
set<int>a;
set<int>::iterator it;
int main()
{
int i, j, k;
int n, m;
while (scanf("%d%d",&n,&m)!=EOF)
{
a.clear();
for (i = 1; i <= n; i++)
{
scanf("%d",&k);
a.insert(k);
}
for (i = 1; i <= m; i++)
{
scanf("%d",&k);
//if (a.find(k) == a.end())
//因为set是实现覆盖的不重复的,所以可以直接插入
a.insert(k);
}
for (it = a.begin(), i = 1; it != a.end(); it++, i++)
{
if (i == a.size())
{
printf("%d\n",*it);
}
else
{
printf("%d ",*it);
}
}
}
return 0;
}
Hdu1412set实现集合合并
最新推荐文章于 2022-06-29 23:57:06 发布