A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://TheAlgorithms.github.io/C-Plus-Plus/dc/d5a/rat__maze_8cpp_source.html below:

TheAlgorithms/C++: backtracking/rat_maze.cpp Source File

Go to the documentation of this file. 46template

<

size_t

size>

48 const

std::array<std::array<int, size>, size> &maze,

49

std::array<std::array<int, size>, size> soln) {

50 if

((currposrow == size - 1) && (currposcol == size - 1)) {

51

soln[currposrow][currposcol] = 1;

52 for

(

int

i = 0; i < size; ++i) {

53 for

(

int

j = 0; j < size; ++j) {

54

std::cout << soln[i][j] <<

" "

;

56

std::cout << std::endl;

60

soln[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)) {

75

soln[currposrow][currposcol] = 0;

88

std::array<std::array<int, size>, size> maze = {

89

std::array<int, size>{1, 0, 1, 0}, std::array<int, size>{1, 0, 1, 1},

90

std::array<int, size>{1, 0, 0, 1}, std::array<int, size>{1, 1, 1, 1}};

92

std::array<std::array<int, size>, size> soln{};

95 for

(

int

i = 0; i < size; ++i) {

96 for

(

int

j = 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