給你兩個集合,要求{A} + {B}. 注:同一個集合中不會有兩個相同的元素.
Input每組輸入數據分爲三行,第一行有兩個數字n,m(0<n,m<=10000),分別表示集合A和集合B的元素個數.後兩行分別表示集合A和集合B.每個元素爲不超出int範圍的整數,每個元素之間有一個空格隔開.Output針對每組數據輸出一行數據,表示合併後的集合,要求從小到大輸出,每個元素之間有一個空格隔開.Sample Input1 2 1 2 3 1 2 1 1 2Sample Output
1 2 3 1 2
#include <iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<stdio.h>
#include<string.h>
using namespace std;
const long long mod = 1e9 + 7;
typedef long long ll;
struct catten
{
int start, end,last;
}cat[101];
bool cmp(catten a, catten b)
{
if(a.end!=b.end)
return a.end < b.end;
return a.last < b.last;
}
int main()
{
int n, m,a[23333];
while (cin >> n >> m)
{
for (int i = 1;i <= n + m;i++)
cin >> a[i];
sort(a + 1, a + 1 + n+m);
printf("%d", a[1]);
for (int i = 2;i <= n + m;i++)
{
if (a[i] != a[i - 1])
{
printf(" %d", a[i]);
}
}cout << endl;
}
}