CJCoding With Joseph
15free / daySign inCreate account

Set Algebra From Input

Read two lines from standard input. The first line holds the integers of set A and the second line the integers of set B, separated by spaces. A line may repeat a value, and every line contains at least one integer.

Then print exactly three lines, in this order:

1. The label Union: followed by every value that is in A or B (or both), ascending.
2. The label Intersection: followed by every value that is in both A and B, ascending.
3. The label A only: followed by every value that is in A but not in B, ascending.

Each label is followed by one space, then the values separated by single spaces (a trailing space after the last value is fine). If a result has no values, print (none) in place of the values, for example A only: (none).

Example input:
1 2 3
2 3 4

The output for that input is shown in Expected Output.

Expected Output:

Union: 1 2 3 4
Intersection: 2 3
A only: 1
Union: 5 6
Intersection: 5 6
A only: (none)
Union: 1 4 9
Intersection: (none)
A only: 1 4

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

Hints4 available
Topics:
STL ContainersSets
📥 Auto-Input:
1 2 3\n2 3 4\n
This input is automatically fed to your program's stdin
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.