Symmetric Difference
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x,y,i,j,f;
cout<<"Enter the size of first array :";
cin>>x;
cout<<"Enter the size of second array :";
cin>>y;
int a[x], b[y],c[x+y];
cout<<"Enter the elements of first array :";
for(i=0;i<x;i++)
cin>>a[i];
cout<<"Enter the elements of second array :";
for(i=0;i<y;i++)
cin>>b[i];
for(i=0;i<x;i++)
{
f=0;
for(j=0;j<y && f==0;j++)
if(a[i]==b[j])
f=1;
if(f==0)
cout<<a[i]<<" ";
}
for(i=0;i<y;i++)
{
f=0;
for(j=0;j<x && f==0;j++)
if(b[i]==a[j])
f=1;
if(f==0)
cout<<b[i]<<" ";
}
}
Comments
Post a Comment