/* Perform the maze: Find all paths */
/* Allroadmaze_20050128.c (recursive )*/
/* 2005-1-28 */
/* Output the result to the text file "c: \ route.txt "*/
/* First output the maze map represented by 01 */
/* Then output all feasible paths */
/* The Maze map uses 0 to indicate space 1 as the obstacle */
/* The abscissa ranges from left to right from 0 1 2 3 ...*/
/* The vertical coordinates are 0 1 2 3 from top to bottom ...*/
# Include <stdlib. h>
# Include <time. h>
# Include <math. h>
# Include <stdio. h>
# Include "conio. h"
# Define N 5
# Define M 5
# Define maxlen m * N
Int time1 = 0;
Int bg [M] [N];
Int aa [M] [N];
Struct pace {
Int dir;
Int ri;
Int rj;
} Road [MAXLEN];
FILE * fp;
Int length = 0;
Int dj [] = {1, 0,-1, 0 };
Int di [] = {0, 1, 0,-1 };
Void makebg (int, int );
Int go (int, int, int );
Int main () {/* main () start */
Int step = 20;
Int len = 10;
Int size = 20;
Int x = 0, y = 0;
Int I = 0;
Makebg (M, N );
If (fp = fopen ("c: \ route.txt", "w") = NULL ){
Printf ("Cannot open teh file! N ");
Return (-1 );
}
Outputmap ();
Go (0, 0, 0 );
Getch ();
Fclose (fp );
}
/* Main () ends */
/* Randomly generate an array representing the maze map */
Void makebg (int a, int B ){
Int I, j;
Int ran;
Int direc;
/* Initialize the maze map */
For (I = 0; I <a; I ++)
For (j = 0; j <B; j ++)
Bg [I] [j] = 1;
/* Randomly generate a maze path */
Randomize ();
I = j = 0; direc = 2;
While (1 ){
Bg [I] [j] = 0;
If (I> = M-1 & j> = N-1) break;
Ran = (int) rand () * 4;
If (ran <1 ){
If (direc! = 1 & I <A-1 ){
I ++;
Direc = 3;
}
<