Answer the question
In order to leave comments, you need to log in
How to merge two non-sets correctly?
Hello! When studying sets, the question arose: How to correctly combine two non-sets of this type (namely, the left side)?
I know how to implement the intersection of the right side:
set<int> inter_no_AB;
set_intersection(begin(universum_diff_A), end(universum_diff_A),
begin(universum_diff_B), end(universum_diff_B),
inserter(inter_no_AB, begin(inter_no_AB)));
set<int> diff_union;
set_union(begin(universum_diff_A), end(universum_diff_A),
begin(universum_diff_B), end(universum_diff_B),
inserter(diff_union, begin(diff_union)));
Answer the question
In order to leave comments, you need to log in
If the initial sets are given, then something like this:
set<int> A_union_B;
set<int> diff_union;
set_union(begin(A), end(A),
begin(B), end(B),
inserter(A_union_B, begin(A_union_B)));
set_difference(begin(universum), end(universum),
begin(A_union_B), end(A_union_B),
inserter(diff_union, begin(diff_union)));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question