• Write a program in C++ to compute the union, intersection, or difference of given input sets. Elements of the sets are
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
• Write a program in C++ to compute the union, intersection, or difference of given input sets. Elements of the sets are
• Write a program in C++ to compute the union, intersection, or difference of given input sets. Elements of the sets are restricted to single digits (0 to 9). For the input and output, the sets are represented as strings of digits. For example, the set {4,8} is represented as either the string "48" or "84" (note that the order is not relevant). The empty set (0) is represented by the string "empty". The input can be one of two types: The form "[first set] [op] [second set]", where [op] is either the character "U", "I", or "D" representing the union, intersection, or difference operations respectively. There is a space on both sides of the operation character. This type of input can be entered multiple times. The character "X" only, to indicate the end of the program. If the user inputs "X", the program should terminate. Otherwise, the program should output the result of the operation and allow the user to enter new input. There should be a new line after each output. Sample Input: 1234 U 2468 1234 I 2468 1234 D 2468 2468 D 1234 605 U empty empty I 605 605 D empty empty D 605 X Sample Output: 132468 24 13 68 605 empty 605 empty