<
size_tsize>
48 conststd::array<std::array<int, size>, size> &maze,
49std::array<std::array<int, size>, size> soln) {
50 if((currposrow == size - 1) && (currposcol == size - 1)) {
51soln[currposrow][currposcol] = 1;
52 for(
inti = 0; i < size; ++i) {
53 for(
intj = 0; j < size; ++j) {
54std::cout << soln[i][j] <<
" ";
56std::cout << std::endl;
60soln[currposrow][currposcol] = 1;
63 if((currposcol < size - 1) && maze[currposrow][currposcol + 1] == 1 &&
64 solveMaze(currposrow, currposcol + 1, maze, soln)) {
69 if((currposrow < size - 1) && maze[currposrow + 1][currposcol] == 1 &&
70 solveMaze(currposrow + 1, currposcol, maze, soln)) {
75soln[currposrow][currposcol] = 0;
88std::array<std::array<int, size>, size> maze = {
89std::array<int, size>{1, 0, 1, 0}, std::array<int, size>{1, 0, 1, 1},
90std::array<int, size>{1, 0, 0, 1}, std::array<int, size>{1, 1, 1, 1}};
92std::array<std::array<int, size>, size> soln{};
95 for(
inti = 0; i < size; ++i) {
96 for(
intj = 0; j < size; ++j) {
Functions for Rat in a Maze algorithm.
static void test()
Self-test implementations.
bool solveMaze(int currposrow, int currposcol, const std::array< std::array< int, size >, size > &maze, std::array< std::array< int, size >, size > soln)
Solve rat maze problem.
int main()
Main function.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4