Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include using namespace std; enum { space = ' ', path = '@' }; void printmaze(char**maze, int row, int col) { // Display

#include #include

#include

using namespace std;

enum { space = ' ', path = '@' };

void printmaze(char**maze, int row, int col) { // Display the result for (int i = 0; i { for (int j = 0; j

cout

cout

}

}

bool done = false; void find_paths(char**m, int rows, int cols, int r, int c) { if (done) { return; } if (r == rows - 1) { printmaze(m, rows, cols); done = true; } else { if (r > 0 && m[r - 1][c] == space) // UP { m[r - 1][c] = path; find_paths(m, r - 1, c, rows, cols); m[r - 1][c] = space; } if (m[r + 1][c] == space) // DOWN { m[r + 1][c] = path; find_paths(m, r + 1, c, rows, cols); m[r + 1][c] = space; } if (c > 0 && m[r][c - 1] == space) // LEFT { m[r][c - 1] = path; find_paths(m, r, c - 1, rows, cols); m[r][c - 1] = space; } if (c

int main() { // Variable Declaration int row, col;

// Holds the maze structure from input file ifstream inputfile; // Variable to read the input file

// Open the input file and exit if file not found inputfile.open("maze.dat"); if (inputfile.eof()) { cout

// Read and display the size of maze inputfile >> row >>col; cout

// Read the maze structure from input file and store in maze[][] array string line; char** maze; maze = new char*[row + 1]; for (int i = 0; i

} int i = 0; getline(inputfile, line); while (getline(inputfile, line) && i { for (int j = 0; j

} printmaze(maze, row, col); find_paths(maze, row, col, 1, 0);

// Close the file inputfile.close();

system("pause"); return 0; }

Please help! I couldn't find any code error... Thank you!

The problem called RECURSIVELY FINDING PATHS THROUGH A MAZEimage text in transcribedPlease, if you do not know what is wrong, let other people help me. Please, do not copy the code from google again. I really need help here. Thank you very much!

Maze.dat:

20 20 + ++++++++++++++++++ + + ++ +++ +++ ++++++ ++ ++ + +++ +++ ++++ + + ++ ++++++ + +++ ++ ++ ++ + + +++ ++++ ++ ++ + + ++++ ++ +++++ + + + +++ +++ + + ++ + +++ ++++++ ++ + +++++ +++ ++ + +++ ++++ ++ ++ + ++++ +++ + +++ +++++++++++ + ++ +++++++ + ++ +++ ++++++++ + ++ ++++++ + + + +++ ++++++ +++ ++++ +++ +++ +++++++++++++ ++++++

ES CAWINDOWS\system32.cmd.exe 20 20 ConsoleApplication4.exe ConsoleApplication4.exe has stopped working A problem caused the program to stop working correctly Windows will close the program and notify you if a solution is available. Debug Close prog ES CAWINDOWS\system32.cmd.exe 20 20 ConsoleApplication4.exe ConsoleApplication4.exe has stopped working A problem caused the program to stop working correctly Windows will close the program and notify you if a solution is available. Debug Close prog

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

Oracle Solaris 11.2 System Administration (oracle Press)

Authors: Harry Foxwell

1st Edition

007184421X, 9780071844215

More Books

Students also viewed these Databases questions

Question

7. Where Do We Begin?

Answered: 1 week ago