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
int startingIndex = 1;
for(int i = 0; i < row; i++){
vector
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
// 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
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