-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfds1.txt
108 lines (108 loc) · 1.95 KB
/
fds1.txt
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#include<iostream>
using namespace std;
class Set
{
int x,y,z;
int *SetA,*SetB;
public:
void getdata();
void calcase1();
void calcase2();
void calcase3();
void calcase4();
void calcase5();
int common();
};
int Set::common()
{
int common=0;
for(int i=y-1;i>=0;i--)
{
for(int j=z-1;j>=0;j--)
{
if(SetA[i] == SetB[j])
{
common++;
}
}
}
return common;
}
void Set::getdata()
{
cout<<"\nEnter the Total number of Students in the class:- ";
cin>>x;
cout<<"\nEnter the Set A (Cricket):- ";
cin>>y;
SetA=new int[y];
for(int i=0;i<y;i++)
{
cout<<"\nEnter The Roll number of "<<i+1<<" student:- ";
cin>>SetA[i];
}
cout<<"\nEnter the Set B (Badminton):- ";
cin>>z;
SetB=new int[z];
for(int i=0;i<y;i++)
{
cout<<"\nEnter The Roll number of "<<i+1<<" student:- ";
cin>>SetB[i];
}
}
void Set::calcase1()
{
cout<<"\nSet of students who play either cricket or badminton or
both:- "<<y+z-common()<<endl;
}
void Set::calcase2()
{
cout<<"\nSet of students who play both cricket and badminton:-
"<<common()<<endl;
}
void Set::calcase3()
{
cout<<"\nSet of students who play only cricket:- "<<ycommon()<<endl;
}
void Set::calcase4()
{
cout<<"\nSet of students who play only badminton:- "<<zcommon()<<endl;
}
void Set::calcase5()
{
cout<<"\nNumber of students who play neither cricket nor
badminton:- "<<x-y-z+common()<<endl;
}
int main()
{
int n;
Set obj;
obj.getdata();
for(int i=1;i<=5;i++)
{
cout<<"\n1. Set of students who play either cricket or badminton
or both \n2. Set of students who play both cricket and badminton
\n3. Set of students who play only cricket \n4. Set of students who
play only badminton \n5. Number of students who play neither
cricket nor badminton \n6. Enter your choice :- ";
cin>>n;
switch(n)
{
case 1:
obj.calcase1();
break;
case 2:
obj.calcase2();
break;
case 3:
obj.calcase3();
break;
case 4:
obj.calcase4();
break;
case 5:
obj.calcase5();
break;
}
}
return 0;
}