恒生电子笔试题
中,并返回非0。如果没找到可以到达终点的路径,返回0。返回的"maze"中除了路径之外其它都清空为0。如下表:
struct NODE { int row; int col; int value; struct NODE* pNodes[8]; int nNeighborNum; };
struct PATH { struct NODE* pCur; struct NODE* pNext; };
void init_maze(int maze[8][8], struct NODE maze_map[8][8]) { // save maze info into maze_map }
int check_end(struct NODE* pNode) { // check if the end position is beside }
struct NODE* get_neighbor(struct NODE** pNode, struct PATH cur) { // get neighbor node which has not been checked }
void add_checked_neighbor(struct NODE** pNode, struct NODE* pNeighbor) { // add neighbor node to the checked node list, // the next time get_neighbor() will not choose it }
int path(int maze[8][8]) { struct PATH path[64] = {}; struct NODE maze_map[8][8] = {}; struct NODE* node_examed[64] = {}; init_maze(maze, maze_map); int nCurPath = 0; path[nCurPath].pCur = &maze_map[0][0]; path[nCurPath].pNext = NULL; add_checked_neighbor(node_examed, &maze_map[0][0]);
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库恒生电子笔试题3(6)在线全文阅读。
相关推荐: