# 【单链表】集合合并

4 5
12 34 56 78
34 67 89 34 76

7
12 34 56 78 67 89 76

#include<iostream>
using namespace std;
template<class T>
struct Node
{
T data;
Node<T> *next;
};
template<class T>
{
public:
bool Locate(T x);
void Insert(T a[], int n);
void PrintList();
Node<T> *first;
};
template <class T>
{
Node<T> *s, *r;
first = new Node<T>;
//first=NULL;
r = first;
for (int i = 0; i < n; i++)
{
s = new Node<T>;
s->data = a[i];
r->next = s;
r = s;
}
r->next = NULL;

}
template <class T>
{
first = new Node<T>;
first->next = NULL;
}
template <class T>
{
Node<T> *p;
while (first->next)
{
p = first->next;
delete first;
first = p;
}
delete first;
}
template<class T>
{
Node<T> *p;
p = first->next;
while (p)
{
cout << p->data << " ";
p = p->next;
}
cout << endl;
}
template <class T>

Node<T> *p;
p = first->next;
while (p != NULL)
{
if (p->data == x)
return true;
p = p->next;
}
return false;
}

int main()
{
int k1, k2;
bool work;
cin >> k1 >> k2;
int count = k1;
int a[1000];
int b[1000];
int c[2000];
for (int i = 0; i < k1; i++)
{
cin >> a[i];
c[i] = a[i];
}
list1.Insert(a, k1);
for (int i = 0; i < k2; i++)
{
cin >> b[i];
if (list1.Locate(b[i]) == false)
{
c[count++] = b[i];
}
}
list2.Insert(c, count);
cout << count << endl;
list2.PrintList();
return 0;
}