Example of a rat's maze Program

Source: Internet
Author: User

/* Configure /*--------------------------------------------------------------------------------------------
// File name: MazeMouse. cpp
// Skill: Find all paths and shortest paths out of the maze.
// Prepared by: sun exposure week
Optional --------------------------------------------------------------------------------------------*/
/* Configure /*--------------------------------------------------------------------------------------------
// Modify record: number date modifier remarks

// 0 2003.04.14 sun exposure weekly Creation
Optional --------------------------------------------------------------------------------------------*/

# Include "stdafx. h"
# Include "iostream. h"
# Include "string. h"
# Include "stdio. h"

Double dMeans = 0, dw.len = 10000; // dMeans indicates the method for going out of the maze. dw.len indicates the minimum number of steps currently going out of the maze.
Char Maze [10] [52] = {
{"###################################### #############"},
{"% #################"},
{"##################################"},
{"######################"},
{"##########################"},
{"########################"},
{"#################################"},
{"######################"},
{"########################@"},
{"###################################### #############"},
}; // Maze
Int MazeFlag [10] [51]; // The Sign of the Maze: 0 indicates that it has not passed, I (I = 1, 2, 3, 4) indicates that it has passed, and I indicates the direction.
Int MazeMin [10] [51]; // The Sign of the maze with the smallest path

Void Walk (int nx, int ny); // a function that follows the maze. nx indicates a column and ny indicates a row.
Void PrintOut (); // print the path and the function of the maze, and compare the walking method that obtains the shorter path.
Int Judge (int nx, int ny, int I); // determines whether the row in column nx can go in the direction of column I. If yes, 1 is returned. Otherwise, 0 is returned.
// I = 1 indicates right, 2 indicates down, 3 indicates left, 4 indicates up

<

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.