Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language: C++ Hey, i need help writing a function void solveMaze(vector > maze, int x, int y) {} that takes in a maze and the

Language: C++

Hey, i need help writing a function void solveMaze(vector> maze, int x, int y) {} that takes in a maze and the end destination and the output has to print the coordinate path of the solved maze.

image text in transcribedThe existing code is as follows...

#include #include #include #include #include

using namespace std;

vector> getInput() { string line; getline(cin, line);

string token;

int rowNum=0; int colNum=0; int size=0; int currSize = 0;

int test;

//get size stringstream lineStream(line); while(lineStream >> token) { size++; }

//initialize 2D vector vector> numbers(size, vector(size, 0));

//read lines

for (int k = 0; k

stringstream lineStream2(line); currSize = 0; while(lineStream2 >> token) {

test = stoi(token); numbers[rowNum][currSize] = test; currSize++; } rowNum++; getline(cin, line);

} //do the last line stringstream lineStream2(line); currSize = 0; while(lineStream2 >> token) {

test = stoi(token); numbers[rowNum][currSize] = test; currSize++; }

return numbers; }

void solveMaze(vector> maze, int x, int y) { //your code here }

int main() { vector> maze; maze = getInput(); int x; cin >> x; int y; cin >> y;

solveMaze(maze, x, y);

return 0; }

You will use a stack to solve a maze. The input is an array of 1s and Os and the row and column of the destination. 1 means that the block can be used for a path to the destination and 0 means it cannot. The beginning of the path is 0, 0. The output is the series of coordinates (row, column) of the path to the destination. Your code will be checked to ensure that you used a stack. The path can proceed up, down, left or right but not diagonally The main method will read in the input and place it into an array. write the method solveMaze It will pass the array and the destination into a method called solveMaze. You Sample Input1 1 0 1 1 11 1 0 0 1 0 1 2 3 Sample Output 1

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

Database And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

More Books

Students also viewed these Databases questions

Question

Define procedural justice. How does that relate to unions?

Answered: 1 week ago