Question
I need some help regarding this question ... https://www.chegg.com/homework-help/questions-and-answers/know-set-function-works--dont-know-implement-c-program-question-problem-user-need-add-inpu-q91602472?trackid=GoFFYiTr Yes i know that this has been answered but ... i have some issues regarding this
I need some help regarding this question ...
https://www.chegg.com/homework-help/questions-and-answers/know-set-function-works--dont-know-implement-c-program-question-problem-user-need-add-inpu-q91602472?trackid=GoFFYiTr
Yes i know that this has been answered but ... i have some issues regarding this where when the user select one of the operation especially 3 and 4 ... the output seems to be wrong and could be some kind of logical error but i just couldnt find it... an explanation in the source code using comment would be greatly appreicated ...
#include
int main() { set
int m, n, l, k; cout > m; cout > n; cout > l;
cout > k; set1.insert(k); }
cout > k; set2.insert(k); }
cout map; for (int i = 1; i > k1 >> k2; map[k1] = k2; }
for (int p = 0; p > ch;
if (ch == 1) { cout v1(set1.begin(), set1.end()), v2(set2.begin(), set2.end()); set
sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end());
for (int i = 0, j = 0; i v2[j]) j++; }
for (auto it = inter.begin(); it != inter.end(); it++) cout
else if (ch == 2) { cout Union; for (auto it = set1.begin(); it != set1.end(); it++) Union.insert(*it); for (auto it = set2.begin(); it != set2.end(); it++) Union.insert(*it);
for (auto it = Union.begin(); it != Union.end(); it++) cout
else if (ch == 3) { cout
int s{}; for (auto i : map) { int a = i.first, b = i.second, s = 0; for (auto j : map) {
if (j.first == b) { s = 1; break; } } if (s == 0) break; }
if (s == 0) cout
else if (ch == 4) { cout
if (s == 0) cout
return 0; }
the output using the same sample from the question :
enter size of first set:4 enter size of second set:4 enter size of relation: 6 enter elements of first set 1 2 3 4 enter elements of second set 2 4 6 8 ana enter elements of relation 1 2 21 - 2 2 24 33 4 4 select ONE opearation 1. Set Intersection operation 2. Set Union operation 3.Determine transitive 4.Determine symmetric 1 your opinion is - 1.Set Intersection operation: 24 select ONE opearation 1. Set Intersection operation 2. Set Union operation 3.Determine transitive 4.Determine symmetric 4 your opinion is - 3. Determine symmetric: NOStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started