Write a program that uses recursive function to identify the path in a given maze. The layout of the maze is written in a file called mazexxx.txt (xxx represent three digit, maze123.txt) that contains a two dimensional array. The array has 0, 1, S,F as its values. 0 indicates the square that is blocked and 1 indicates the square that you can go through. S indicates the starting square and F indicates the finishing square. See below for an example layout of a maze.
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 1 | 0 |
0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 |
0 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 |
0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 0 |
0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 |
0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 0 |
0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 0 |
0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 1 | 1 | 0 |
0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 |
0 | S | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | F | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Your program should also display the found path by drawing X along the path (see below) and write the maze with the found path to another file called solxxx.txt (e.g., sol123.txt).
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | |
0 | X | X | X | X | X | X | X | X | 0 | 1 | 1 | 1 | 1 | 0 |
0 | X | 0 | 0 | 0 | 0 | 0 | 0 | X | 0 | 0 | 0 | 0 | 1 | 0 |
0 | X | 1 | 1 | 1 | 1 | 0 | 0 | X | 1 | 1 | 1 | 1 | 1 | 0 |
0 | X | 0 | 0 | 0 | 1 | 0 | 0 | X | 0 | 0 | 0 | 0 | 0 | 0 |
0 | X | X | X | 1 | 1 | 0 | 0 | X | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | X | 0 | 0 | 0 | 0 | X | X | X | X | 1 | 1 | 0 |
0 | 0 | 0 | X | 0 | 0 | 0 | 0 | 0 | 0 | 0 | X | 0 | 1 | 0 |
0 | 0 | 0 | X | X | X | X | X | X | 1 | 0 | X | 0 | 1 | 0 |
0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | X | 0 | 0 | X | 0 | 1 | 0 |
0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | X | 0 | 0 | X | 0 | 0 | 0 |
0 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | X | 0 | X | X | 1 | 1 | 0 |
0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | X | 0 | X | 0 | 0 | 0 | 0 |
0 | S | X | X | X | X | X | X | X | 0 | X | X | X | F | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Reviews
There are no reviews yet.