Question: In C++, how would you compare two vectors with one vector requiring all elements from the second vector in order to pass ? Example 1:
In C++, how would you compare two vectors with one vector requiring all elements from the second vector in order to pass?
Example 1:
Let's say our required vector has gotten us X, Y, Z
And our input vector has gotten us W, B, Z, Y, B, X
You would have a function that would read through each element from the input vector and compare its elements to the elements in the required vector in order to pass, such as in an if-else statement. If our elements in the input vector succeeds in having matching ALL OF the elements from the required vector, output an instance of say: "Vector complete". Let's look at another example,
Example 2:
Let's say our required vector has gotten us X, Y, Z, T
And our input vector has gotten us T, B, W, L, A
If our input vector is missing even one of the elements from the required vector, output every element that is missing from the input vector, in this case: "You are missing X Y Z", Let's look at another example
Example 3:
Let's say our required vector again has gotten us X, Y, Z, T
And our input vector this time has gotten us M, B, W, L, A or M, M, W, L, L
If our input vector doesn't match the required vector at all, output the message "Vector unacceptable", finally last example
Example 4:
Let's say our required vector has gotten us X, Y, Z
And our input vector has gotten us Z, W, Z, Y, B, X, X
If our program detected that in our input vector that there are duplicates in our vector, you would print each element out, as well as their index in following output message:
"Duplicates:"
"Z found at index 0"
"Z found at index 2"
"X found at index 5"
"X found at index 6"
Please use whatever methods you need to achieve the following outputs, if you need more information, please comment more than just "more information" if you want specifics, Thank you so much for your time
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
