Question: Given the following code in C++: #include #include using namespace std; int main() { srand(time(NULL)); cout < < Enter # of rows: ; int row;

Given the following code in C++:

#include

#include

using namespace std;

int main() {

srand(time(NULL));

cout << "Enter # of rows: ";

int row;

cin >> row;

cout << "Enter # of columns: ";

int column;

cin >> column;

vector > numberBoard;

int startingIndex = 1;

for(int i = 0; i < row; i++){

vector temp;

for(int j = 0; j < column; j++){

temp.push_back(startingIndex);

startingIndex++;

}

numberBoard.push_back(temp);

}

cout <<"Number Board:" << endl;

for(int i = 0; i < numberBoard.size(); i++){

for(int j = 0; j < numberBoard[i].size(); j++){

cout.width(5);

cout << numberBoard[i][j];

}

cout << endl;

}

vector > hiddenBoard(row, vector(column));

// looping through outer vector vec

for (int i = 0; i < row; i++) {

// looping through inner vector vec[i]

for (int j = 0; j < column; j++) {

int random = rand()% 32 + 65;

(hiddenBoard[i])[j] = char(random);

//i*n + j;

}

}

cout << " Board:" << endl;

for(int i = 0; i < hiddenBoard.size(); i++){

for(int j = 0; j < hiddenBoard[i].size(); j++){

cout.width(5);

cout << hiddenBoard[i][j];

}

cout << endl;

}

return 0;

}

How do I try to put both vectors into a key-value map so if example, element 3 in numberBoard can access the value of element 3 in position of hiddenBoard to match.

Essentially a matching game, where the hiddenBoard are the ones you need to match and numberBoard is merely used to access the position of hiddenBoard.

If user input chooses: 3 as the first slot, and 7 as the second slot. Match the same position (like row, and column) so that to check if they match and cout whether they match or not

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!