这里运用了set
附上大佬set的用法:http://www.cnblogs.com/BeyondAnyTime/archive/2012/08/13/2636375.html
同时有相关的map的用法:
http://blog.csdn.net/hero_myself/article/details/52313451
#include <iostream>
#include <set>
using namespace std;
int main()
{
set<int> S;
int m, n, a;
set<int>::iterator ite;
while(cin >> m >> n)
{
S.clear();
for(int i = 0; i < m; i++)
{
cin >> a;
S.insert(a);
}
for(int j = 0; j < n; j++)
{
cin >> a;
S.insert(a);
}
for(ite = S.begin(); ite != S.end(); ++ite)
{
if(ite == S.begin())
cout << *ite;
else
cout <<' '<< *ite;
}
cout<<endl;
}
return 0;
}