恒生电子笔试题3(6)
时间:2025-03-11
时间:2025-03-11
恒生电子笔试题
中,并返回非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]);
上一篇:09级电信二班赵晓飞毕业论文