Please HELP how can this code display only for these paths, what needs to be changed c++ #include #include const int WIDTH = 6; const int HEIGHT = 5; void check(int x, int y, int dest_x, int dest_y, int (&maze)[HEIGHT][WIDTH], std::string& path) { if (x < 0 || y < 0 || x >= WIDTH|| y >= HEIGHT || !maze[y][x]) { return; } int len = path.size(); path += (char) ('0' + x); path += ','; path += (char) ('0' + y); if (x == dest_x && y == dest_y) { std::cout << path << "\n"; } else { path += " > "; maze[y][x] = 0; check (x + 0, y - 1, dest_x, dest_y, maze, path); check (x + 0, y + 1, dest_x, dest_y, maze, path); check (x - 1, y + 0, dest_x, dest_y, maze, path); check (x + 1, y + 0, dest_x, dest_y, maze, path); maze[y][x] = 1; } path.resize(len); } int main() { int maze[HEIGHT][WIDTH] = { {1,0,1,1,1,1}, {1,0,1,0,1,1}, {1,1,1,0,1,1}, {0,0,0,0,1,0}, {1,1,1,0,1,1}}; std::string path; check(0, 0, 4, 3, maze, path); return 0; }
Please HELP
how can this code display only for these paths, what needs to be changed c++
#include <iostream>
#include <string>
const int WIDTH = 6;
const int HEIGHT = 5;
void check(int x, int y, int dest_x, int dest_y,
int (&maze)[HEIGHT][WIDTH], std::string& path) {
if (x < 0 || y < 0 || x >= WIDTH|| y >= HEIGHT || !maze[y][x]) {
return;
}
int len = path.size();
path += (char) ('0' + x);
path += ',';
path += (char) ('0' + y);
if (x == dest_x && y == dest_y) {
std::cout << path << "\n";
} else {
path += " > ";
maze[y][x] = 0;
check (x + 0, y - 1, dest_x, dest_y, maze, path);
check (x + 0, y + 1, dest_x, dest_y, maze, path);
check (x - 1, y + 0, dest_x, dest_y, maze, path);
check (x + 1, y + 0, dest_x, dest_y, maze, path);
maze[y][x] = 1;
}
path.resize(len);
}
int main() {
int maze[HEIGHT][WIDTH] = {
{1,0,1,1,1,1},
{1,0,1,0,1,1},
{1,1,1,0,1,1},
{0,0,0,0,1,0},
{1,1,1,0,1,1}};
std::string path;
check(0, 0, 4, 3, maze, path);
return 0;
}
![1, 1, 1, 1, 1 },
1, 2, 1, е, 1 },
8, 1 },
0, 1, 0, 0, 1 },
0,
},
1, 1, 1, а, },
1 1, 1, 1 },
1, 1, 1, 0, 1 },
в, 1, 1, 8, 1 },
0,
, 1, 1, 1, 1 },
1,, 1, e, 1 },
0, 1, 1, 0, 1 },
0,
а, 1, 1, а,
},
в, 1, а, в, 1},
в, 1, 1, 1, 1}
а, в, 1 },
0,
в, в, 1 },
0, 1. 1. 1, 1}
1 1, 1, 1 },
в, 1 },
, 0, 1 },
0, , 0, 0, 1 },
+}
1, 1,
0,](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa6fa9c15-3f80-48ac-99d6-064cce8dc358%2F685f1b8e-e0d6-450d-9d42-88df34d28918%2F2shd0i_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 3 steps with 3 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)