Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ program Write a C++ (or Java, etc.) function and test program to accomplish the following: Considering the following C++ declaration: int A[2]; // A

C++ program

image text in transcribedimage text in transcribedimage text in transcribed

Write a C++ (or Java, etc.) function and test program to accomplish the following: Considering the following C++ declaration: int A[2]; // A is a set of 2 elements int B[3]={1,2,3); // B is a set of 3 elements int C[2]; // C is a set of 2 elements Requirements: a) Input numbers for A and input for C (i.e cin >> x >>y) b) Do the Cartesian product in example 1.2.7 c) Output all ordered pair and ordered triples. Cartesian Products Example: 1.2.7 (see EppDM5e_01_02.pdf) Let A = {x, y}, B = {1, 2, 3), and C = {a, b}. Write the find function for the following: 1) Find AxB 2) Find BA 3) Find AxA 4) How many elements are in A x B, B x A, and AXA 5) Find (A x B) xC 6) Define a relation R from A to B as following: Given any (x,y) means that (x-y) / 2 is an integer. Hints: #include using namespace std; struct Pair { int x; int y; vector find(int x[], int x[], int, int); int main() { int A[2]; // 1,2 int B[3] = { 1, 2, 3 }; int C[2]; // 2,3 cout > A[0] >> A[1]; cout > C[O] >> C[1]; vector axb = find(A, B, 2, 3); // Do a simple output here vector axb = find(A, B, 2, 3); // Do a simple output here string s_axb; for (int i=0; i V; // v = {(1,1) (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (1, 3), (2,2), (2,3)} return v; } Write a C++ (or Java, etc.) function and test program to accomplish the following: Considering the following C++ declaration: int A[2]; // A is a set of 2 elements int B[3]={1,2,3); // B is a set of 3 elements int C[2]; // C is a set of 2 elements Requirements: a) Input numbers for A and input for C (i.e cin >> x >>y) b) Do the Cartesian product in example 1.2.7 c) Output all ordered pair and ordered triples. Cartesian Products Example: 1.2.7 (see EppDM5e_01_02.pdf) Let A = {x, y}, B = {1, 2, 3), and C = {a, b}. Write the find function for the following: 1) Find AxB 2) Find BA 3) Find AxA 4) How many elements are in A x B, B x A, and AXA 5) Find (A x B) xC 6) Define a relation R from A to B as following: Given any (x,y) means that (x-y) / 2 is an integer. Hints: #include using namespace std; struct Pair { int x; int y; vector find(int x[], int x[], int, int); int main() { int A[2]; // 1,2 int B[3] = { 1, 2, 3 }; int C[2]; // 2,3 cout > A[0] >> A[1]; cout > C[O] >> C[1]; vector axb = find(A, B, 2, 3); // Do a simple output here vector axb = find(A, B, 2, 3); // Do a simple output here string s_axb; for (int i=0; i V; // v = {(1,1) (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (1, 3), (2,2), (2,3)} return v; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

Students also viewed these Databases questions

Question

Analyse the process of new product of development.

Answered: 1 week ago

Question

Define Trade Mark.

Answered: 1 week ago