-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymmetric-difference
81 lines (80 loc) · 1.6 KB
/
symmetric-difference
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include<stdio.h>
int main()
{
int a[10],b[10],c[10],d[10],m=0,k=0,n=0,n1,n2,l,i,j,sy[100];
printf("Enter size of set A:-");
scanf("%d",&n1);
printf("Enter element of set:-\n");
for( i=0;i<n1;i++)
scanf("%d",&a[i]);
printf("Enter size of set B:-");
scanf("%d",&n2);
printf("Enter element of set:-\n");
for( i=0;i<n2;i++)
scanf("%d",&b[i]);
for( i=0;i<n1;i++)
{
for(j=0;j<n2;j++)
{
if(b[j]==a[i])
break;
}
if(j==n2)
{
for(l=0;l<k;l++)
{
if(c[l]==a[i])
break;
}
if(l==k)
{
c[k]=a[i];
k++;
}
}
}
for( i=0;i<n2;i++)
{
for(j=0;j<n1;j++)
{
if(b[i]==a[j])
break;
}
if(j==n1)
{
for(l=0;l<m;l++)
{
if(d[l]==b[i])
break;
}
if(l==m)
{
d[m]=b[i];
m++;
}
}
}
printf("\nset A is :- ");
for(i=0; i<n1;i++)
{
printf("%d ", a[i]);
}
printf("\nset B is :- ");
for(i=0; i<n2;i++)
{
printf("%d ", b[i]);
}
for(i=0;i<k;i++)
{
sy[n]=c[i];
n++;
}
for(i=0;i<m;i++)
{
sy[n]=d[i];
n++;
}
printf("\nsymmetric Difference of sets is:- ");
for(i=0;i<n;i++)
printf("%d ",sy[i]);
}