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
using namespace std;
int main() { set
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
{ 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
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
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
Get step-by-step solutions from verified subject matter experts
