Experimental Report 1 Data Structure Experiment 1 Solving Maze Problems Experimental Report 1 Experimental Content Input an 8×6 rectangular maze from the keyboard, and use the program to find a passage from the upper left corner to the lower right corner. Output the path number and route map. If there is no feasible passage, output a prompt. 2 Experimental Method Requirements: Input an 8×6 rectangular 0-1 array from the keyboard. 0 represents a feasible passage, and 1 represents a partition. For the convenience of calculation, add a circle of 1 to the outer periphery of the entire maze to form a \"wall\". It is required to find a path from the upper left corner 0 to the lower right corner 0. Output the coordinates of each point on the path in sequence. Finally, output the maze that has been walked through. Rewrite the 0 of the walking point to 2. Output a prompt message if it is not possible. Implementation: Use a recursive algorithm to check each point around it clockwise for each waypoint you reach, and examine whether it is 0 or has been walked through. If not, examine the next point. If so, walk one step forward to the point and make a similar check. If all the surrounding points are 1 or have been walked through, it proves that this path is blocked. Go back to the previous point to find other paths. End when you reach point [8, 6]. Output the coordinates of each point you have walked through in reverse order, and rewrite the points you have walked through as 2. Finally, output the completed maze. If you return to point [1, 1]. It proves that there is no way to go. Then output a prompt message. Also output the maze. Three source programs #include const int m=6,n=8; //Determine the size of the maze int maze[m+2][n+2]; //Create an array to store the maze structure int mark[m+2][n+2]; //Create an array to record the points you have walked through int move[8][2]={{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1},{-1,0},{-1,1}}; //Direction trial parameter array int SeekPath(int x,int y) //Path seeking function { i……
You Might Like
Recommended ContentMore
Open source project More
Popular Components
Searched by Users
Just Take a LookMore
Trending Downloads
Trending ArticlesMore