#include"iostream.h"
#include"conio.h"
void PrintSet(int X[],int n)
{
cout<<"{";
for(int i=0;i<n;i++)
{
cout<<X[i];
if(i!=n-1)
cout<<",";
}
cout<<"}";
}
int Union(int X[],int nx,int Y[],int ny,int Z[])
{
int nz=0,found=0;
for(int i=0;i<=nx;i++)
{
for(int j=0;j<=ny;j++)
if(Y[j]==X[i])
{
found=1;
break;
}
if(!found)
Z[nz++]=X[i];
}
return nz;
}
void main()
{
int A[20],B[20],C[40],n1,n2,na=0,nb=0,nc;
int x,i;
clrscr();
cout<<"\nPlease enter number of elements in A :";
cin>>n1;
for(int t=1;t<=n1;t++)
{
cin>>x;
int found=0;
for(i=0;i<na;i++)
if(x==A[i])
{
found=1;
break;
}
if(!found)
A[na++]=x;
}
cout<<"A= ";
PrintSet(A,na);
cout<<"\nPlease enter number of elements in B :";
cin>>n2;
for(t=0;t<n2;t++)
{
cin>>x;
int found=0;
for(i=0;i<nb;i++)
if(x==B[i])
{
found=1;
break;
}
if(!found)
B[nb++]=x;
}
cout<<"\nB=";
PrintSet(B,nb);
nc=Union(A,na,B,nb,C);
cout<<"\nC=";
PrintSet(C,nc);
getch();
}