#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
bool U[36],A[36],B[36];
int i,n,m,e;
memset(U,true,sizeof U);
memset(A,false,sizeof A);
memset(B,false,sizeof B);
cout<<"Enter Number Of A Set"<<endl;
cin>>n;
cout<<"Enter Elements="<<endl;
for(i=0;i<n;i++)
{
cin>>e;
A[e]=true;
}
cout<<"Enter Number Of B Set"<<endl;
cin>>m;
cout<<"Enter Elements="<<endl;
for(i=0;i<m;i++)
{
cin>>e;
B[e]=true;
}
cout<<"AUB"<<endl;
for(i=0;i<36;i++)
{
if(A[i] | B[i])
{
printf(" %d",i);
}
}
cout<<endl;
cout<<"A^B"<<endl;
for(i=0;i<36;i++)
{
if(A[i] & B[i])
{
printf(" %d",i);
}
}
cout<<endl;
cout<<"U-A"<<endl;
for(i=1;i<=36;i++)
{
if(U[i] && U[i]^A[i]) //taking uncommon element
{
printf(" %d",i);
}
}
cout<<endl;
cout<<"A-B"<<endl;
for(i=0;i<36;i++)
{
if(A[i] && A[i]^B[i])
{
printf(" %d",i);
}
}
cout<<endl;
return 0;
}
0 comments:
Post a Comment