Question: Using C++ to write three functions 1. sort3: This procedure should input 3 ints and sort them (use pass by reference). (You should not use
Using C++ to write three functions
1. sort3: This procedure should input 3 ints and sort them (use pass by reference). (You should not use vectors in this function.)
2. reverse: This procedure should input a vector of doubles and reverse the order of the entries (use pass by reference)
3. is subset: This function should input two arrays of ints along with two extra variables referring to their sizes (see below). It should return true if every item of the first array is also found in the second array
For is subset, if the first array is {2, 3, 2, 3, 2, 3, 2, 3, 3, 2} and the second array is {2, 3, 2} the answer should be true because every elemet of the first array (2 or 3) is also found in the second one. However, if the first array is {2, 3, 4} and the second array is {2, 3, 2, 3, 5} the answer should be false because of the four.
For sort3: your function should sort the entries in ascending order, (smallest to larrgest) e.g., 2,4,5. It is strongly recommended that you write a helper function named swap for this problem. Do not use max or min.
Now we have the main function below, we just need to write the function. We don't need to edit the main body. int main() {
vector
int x = 3; int y = -2; int z = 1;
sort3(x, y, z);
int a[3] = { 1,2,3 }; int b[4] = { 1,2,3,4 }; is_subset(a, 3, b, 4); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
