Question
//C++ ONLY //Write a program that illustrates how to use the function set_union() and set_intersection(). //Stub program is provided. //TODO are all the fields that
//C++ ONLY
//Write a program that illustrates how to use the function set_union() and set_intersection().
//Stub program is provided.
//TODO are all the fields that need to be done
//I need help fast, please
#include
#include
#include
#include
using namespace std;
int main()
{
int setA[5] = {2, 4, 5, 7, 8};
int setB[7] = {1, 2, 3, 4, 5, 6, 7};
int setC[5] = {2, 5, 8, 8, 15};
int setD[6] = {1, 4, 4, 6, 7, 12};
set set2A(setA,setA+5);
// TODO define set2B initialized from setB
// TODO define set2C initialized from setC
// TODO define set2D initialized from setD
int AunionB[12];
// TODO define AunionB
// TODO define CunionD
// TODO define AintersectB
// TODO define CintersectD
// TODO define finalUnion
// TODO define finalIntersection
set final2Union;
set final2Intersection;
set final2Difference;
int *lastAunionB;
// TODO define lastAunionB
// TODO define other required variables
ostream_iterator screen(cout, " ");
cout << "setA = ";
copy(/* print setA using copy */);
cout << endl;
// TODO print setB, setC, and setD using copy
lastAunionB = set_union( // TODO set AunionB to a union of setA and setB
// TODO );
// TODO print AunionB using copy
// TODO set CunionD to a union of setC and setD
// TODO print CunionD using copy
lastAintersectB = set_intersection(// TODO set AintersectB to an intersection of setA and setB
// TODO );
// TODO print AintersectB using copy
// TODO set CintersectD to an intersection of setC and setD
// TODO print CintersectD using copy
// TODO set finalUnion to a union of setA, setB, setC, and setD
// TODO print finalUnion using copy
// TODO set finalIntersection to an intersection of setA, setB, setC, and setD
// TODO print finalIntersection using copy
set_union(set2A.begin(), set2A.end(), set2B.begin(), set2B.end(), inserter(final2Union, final2Union.end()));
// TODO make final2Union a union of set2A, set2B, set2C, and set2D
// TODO print final2Union using copy
// TODO make final2Intersection an intersection of set2A, set2B, set2C, and set2D
// TODO print final2Intersection using copy
cout << "finalUnion == final2Union : ";
cout << lexicographical_compare(//TODO compare finalUnion and final2Union
) << endl;
// TODO compare finalIntersection and final2Intersection and print the comparison result
return 0;
}
//REPLY ONLY IF YOU KNOW THE CORRECT SOLUTION //DON'T REPLY IF YOU DON'T KNOW THE ANSWER
//THANK YOU
//THIS IS ALL I HAVE, I DIDN'T GET ANYTHING ELSE FOR THIS ASSIGNMENT. THERE IS NO CLASS, HEADER-FILES, OR ANYTHING ELSE.
//THIS IS ALL YOU HAVE TO WORK ON
Step 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