#include<cstdio>
#include<iostream>
#define max 100
#define ok 1;
using namespace std;
typedef int elemtype;
typedef int status;
typedef struct {
elemtype *elem; //記錄相應元素的位置
int last; //記錄最後一個元素的位置
}sqlist;
status initlist(sqlist &L) //初始化線性表
{
L.elem=new elemtype[max];
L.last=0;
return ok;
}
void fuzhi(sqlist &L) //線性表的指派
{
char c;
printf("輸入線性表的各個元素:\n");
for(int i=0;i<max;i++)
{
scanf("%d%c",&L.elem[i],&c);
L.last++;
if(c=='\n')
break;
}
}
void hebing(sqlist &s,sqlist &p) //兩集合并集
{
for(int i=0;i<s.last;i++)
{
int ss=0;
for(int j=0;j<p.last;j++)
{
if(s.elem[i]!=p.elem[j])
ss++;
}
if(ss==p.last)
{
p.elem[p.last]=s.elem[i];
p.last++;
}
}
for(int k=0;k<p.last;k++)
printf("%d ",p.elem[k]);
printf("\n");
}
int main()
{
sqlist s,p;
initlist(s);
initlist(p);
fuzhi(s);
fuzhi(p);
hebing(s,p);
}