Question
Write a C++ program to list all elements in the Cartesian product of these two sets. You will ask user to enter the elements of
Write a C++ program to list all elements in the Cartesian product of these two sets. You will ask user to enter the elements of each set (A and B), then display the Cartesian product of A and B. Turn in the C++ source code (not project file or solution file), with three test cases. Note: set A and B can hold string elements, double, and/or character datatype. It is your choice. Following is an example of A holds integer and B holds characters.
Example of program output:
This program lists all elements in the Cartesian product of sets A and B.
For example: Let A = {1, 2, 3}
Let B = {a, b}
The Cartesian product is:
A X B = { (1, a), (1, b), (2, a), (2, b), (3, a), (3, b) }
Enter integers for set A (no more than 30 numbers, -1 to stop)
1: 1
2: 2
3: 3
4: -1
Enter characters for set B (no more than 30 characters, '.' to stop)
1: a
2: b
3: . set A = { 1, 2, 3 }
set B = { a, b }
The Cartesian product of A and B is
A X B = {
( 1, a ), ( 1, b ), ( 2, a ), ( 2, b ), ( 3, a ), ( 3, b ) } Again (y/n): y
Enter integers for set A (no more than 30 numbers, -1 to stop)
1: 2
2: 4
3: 6
4: 8
5: -1
Enter characters for set B (no more than 30 characters, '.' to stop)
1: x
2: y
3: z
4: .
set A = { 2, 4, 6, 8 }
set B = { x, y, z }
The Cartesian product of A and B is A X B = {
( 2, x ), ( 2, y ), ( 2, z ), ( 4, x ), ( 4, y ), ( 4, z ), ( 6, x ), ( 6, y ), ( 6, z ), ( 8, x ), ( 8, y ), ( 8, z ) } Again (y/n): n
Press any key to continue . . .
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started