Question: I have run some problem with my source code (which is C++) and that is trying to applying two relation and that is the transistive

I have run some problem with my source code (which is C++) and that is trying to applying two relation and that is the transistive and symmetric relation ... i really dont know how to apply these two relation into C++ here is the source code :

#include #include #include #include #include

using namespace std;

int main() { set set1, set2;

int Fset, Sset, l, k; cout << "enter size of first set:"; cin >> Fset; cout << "enter size of second set:"; cin >> Sset; cout << "enter size of relation:"; cin >> l;

cout << "enter elements of first set "; for (int i = 1; i <= Fset; i++) { cin >> k; set1.insert(k); }

cout << "enter elements of second set "; for (int i = 1; i <= Sset; i++) { cin >> k; set2.insert(k); }

cout << "enter elements of relation "; map map; for (int i = 1; i <= l; i++) { int k1, k2; cin >> k1 >> k2; map[k1] = k2; }

{ cout << " select ONE opearation"; cout << " 1.Set Intersection operation"; cout << " 2.Set Union operation"; cout << " 3.Determine transitive"; cout << " 4.Determine symmetric "; int ch; cin >> ch;

if (ch == 1) { cout << "your opinion is - 1.Set Intersection operation:" << endl; vector v1(set1.begin(), set1.end()), v2(set2.begin(), set2.end()); set inter;

sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end());

for (int i = 0, j = 0; i < v1.size() && j < v2.size();) { if (v1[i] == v2[j]) { inter.insert(v1[i]); i++; j++; } else if (v1[i] < v2[j]) i++; else if (v1[i] > v2[j]) j++; }

for (auto it = inter.begin(); it != inter.end(); it++) cout << *it << " "; cout << endl; }

else if (ch == 2) { cout << "your opinion is - 2.Set Union operation:" << endl; set 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 << *it << " "; cout << endl; }

else if (ch == 3) { cout << "your opinion is - 3.Determine transitive:" << endl;

}

else if (ch == 4) { cout << "your opinion is - 4.Determine symmetric:" << endl;

} }

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!