___ ___ ___ ___ ___ | | | | | | | ___ ___| | | | | | | | | | | | | | | | |___| | | | | | | | | | ___| ___ | | | | | | | |___ ___ ___|___ ___|and print this maze as output.
___ ___ ___ ___ ___ | | | | S | | | ___ ___| | | | | | | | | * | | | | | | | |___| | | | | | | * | * * * | | ___| ___ | | | | | * * * | F | |___ ___ ___|___ ___|More precisely, I want you to use the following as the core of a header file "maze.h", and write code for the functions GetMaze(), PrintMaze(), and PrintSolvedMaze().
#define MAZE_MAX 50 typedef struct { int squaresAcross; int squaresDown; int horizontalWall[MAZE_MAX][MAZE_MAX]; int verticalWall[MAZE_MAX][MAZE_MAX]; } maze; void GetMaze( FILE *, maze * ); void PrintMaze( maze * ); void PrintSolvedMaze( maze * );GetMaze() should take a file pointer as input, and return a maze via its second parameter. It is the responsibility of the calling routine to open the appropriate text file. That responsibility might be carried out like this:
FILE *theMazeFile; maze myMaze; char fileName[20] = "mazefile.txt"; theMazeFile = fopen( fileName, "r" ); /* open for reading */ if( theMazeFile == NULL ) { printf( "Can't open %s.\n", fileName ); exit( 1 ); } GetMaze( theMazeFile, &myMaze );
PrintMaze() should print the given maze without the *'s.
PrintSolvedMaze() should print the given maze with an S (Start) at the upper left (position (1,1)), an F at the bottom right (position (width,height)), and *'s along the solution path your program computes.
4 5 The horizontal walls: 1 1 1 1 1 0 1 0 1 0 0 0 1 0 0 0 1 0 1 0 1 1 1 1 1 The vertical walls: 1 0 0 0 1 1 1 1 1 1 1 1 1 0 1 0 0 1 1 0 0 1 0 1
Note that walls are indicated by 1's. Your GetMaze() function should index the horizontalWall[][] and verticalWall[][] fields so that the first index represents the row, and the second represents the column.
Act similarly for the other compass directions.
Start early, keep in touch, and have fun.