Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Print the following key and value from the following map shown in the following code in C++: #include #include #include #include #include using namespace std;

Print the following key and value from the following map shown in the following code in C++:

#include

#include

#include

#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;

}

map, vector > boardMap;

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

boardMap[numberBoard[i]] = hiddenBoard[i];

}

return 0;

}

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

Harness The Power Of Big Data The IBM Big Data Platform

Authors: Paul Zikopoulos, David Corrigan James Giles Thomas Deutsch Krishnan Parasuraman Dirk DeRoos Paul Zikopoulos

1st Edition

0071808183, 9780071808187

More Books

Students also viewed these Databases questions