Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool print_path_through_maze(const maze_node* maze_position)
- // Postcondition: Prints the path through the maze, with 0s representing right
- // turns and 1s representing left turns.
- // You may print the path in reverse order (this will be easier).
- // Hint: Use the return boolean to signify that the current path is the correct path.
- {
- if(maze_position->is_finish()){
- cout << endl << "true-BREAK ";
- return true;
- }
- if(!(maze_position->is_finish()) && (maze_position->left() == 0) && (maze_position->right() == 0)){
- cout << endl << "false-BREAK ";
- return false;
- }
- if(maze_position->left() != 0){
- cout << "L";
- print_path_through_maze(maze_position->left());
- }
- if(maze_position->right() != 0){
- cout << "R";
- print_path_through_maze(maze_position->right());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement