CJCoding With Joseph
15free / daySign inCreate account

Elements Only in the First Set

Write a function set<int> difference(const set<int>& a, const set<int>& b) that returns a new set containing every value that is in a but not in b. Neither input set may be modified.

The test prints the returned set's elements in ascending order separated by single spaces, or the word empty if the returned set has no elements.

For example, with a = {1, 2, 3, 4} and b = {2, 4} the result is {1, 3}, printed as 1 3.

Do NOT write a main function.

Expected Output:

1 3
empty

= newline. The output ends with a newline — print one after the last line.

Hints4 available
Topics:
STL ContainersSets
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.