Set Algebra From Input
hardQuestion 476Read 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, so print one after the last line.
Your output
Run your code to see the output here...