user-0 提问: c语言走迷宫问题，打印不出东西。。。

回复:
user: user-1
content: 你可以看看这本书，代码都有 数据结构课程设计编程实例——基于Win32 API编程  书中的代码和视频见 http://pan.baidu.com/s/1dD5sSgT  http://pan.baidu.com/s/1c0pLPy4

user: user-2
content: 直接递归吧, 看上去也简单, 代码walk几乎不做任何事就退出了.

user: user-3
content: 仅供参考：/**  * @Title  老鼠走迷宫的拓展探究  * @Author 孙琨  * @Date   2013-11-16  * @At     XUST  * @All Copyright by 孙琨  *  */  #include <iostream> using namespace std;  int maze[9][9] = { // 初始化迷宫，英文maze为“迷宫”     {2,2,2,2,2,2,2,2,2},     {2,0,0,0,0,0,0,0,2},     {2,0,2,2,0,2,2,0,2},     {2,0,2,0,0,2,0,0,2},     {2,0,2,0,2,0,2,0,2},     {2,0,0,0,0,0,2,0,2},     {2,2,0,2,2,0,2,2,2},     {2,0,0,0,0,0,0,0,2},     {2,2,2,2,2,2,2,2,2} };  int startI = 1,startJ = 1; // 入口行列坐标 int endI = 7,endJ = 7;     // 出口行列坐标  void visit(int i,int j)  // 自动搜寻路径 {     int m,n;      maze[i][j] = 1;      if((i == endI) && (j == endJ))     {         cout << endl << "显示路径:" << endl;         for(m=0; m<9; m++)         {             for(n=0; n<9; n++)             {                 if(maze[m][n] == 2)                     cout << "■";                 else if(maze[m][n] == 1)                     cout << "♀";                 else                     cout << "  ";             }             cout << endl;         }     }      if(maze[i][j+1] == 0)         visit(i,j+1);     if(maze[i+1][j] == 0)         visit(i+1,j);     if(maze[i][j-1] == 0)         visit(i,j-1);     if(maze[i-1][j] == 0)         visit(i-1,j);      maze[i][j] = 0;  }  int main(void) {     int i,j;      cout << "显示迷宫: " << endl;     for(i=0; i<9; i++)     {         for(j=0; j<9; j++)         {             if(maze[i][j] == 2)                 cout << "■" ;             else                 cout << "  " ;         }         cout << endl;     }      visit(startI,startJ);      return 0; }

user: user-4
content: 可能不是最优解  #include <stdio.h> #include <stdlib.h>  #define MAP_X_SIZE (10) #define MAP_Y_SIZE (10)  #define OK_PASS (1) #define NG_PASS (0)  void print(char map[MAP_X_SIZE][MAP_Y_SIZE]); int walk(char map[MAP_X_SIZE][MAP_Y_SIZE], int x, int y); void push(int x, int y); void pop(int x, int y);  int step = 0; int walked[MAP_X_SIZE][MAP_Y_SIZE];   int main (void)  { 	int i, j; 	char map[MAP_X_SIZE][MAP_Y_SIZE] = //test data 	{             /* 0   1    2	  3    4    5    6	   7   8    9	*/ 	/*00*/	{'o','o','o','o','o','o','o','o','o','o'}, 	/*01*/	{'o',' ',' ','o',' ',' ',' ','o',' ','o'}, 	/*02*/	{'o',' ',' ','o',' ',' ',' ','o',' ','o'}, 	/*03*/	{'o',' ',' ',' ',' ','o','o',' ',' ','o'}, 	/*04*/	{'o',' ','o','o','o',' ',' ',' ',' ','o'}, 	/*05*/	{'o',' ',' ',' ','o',' ',' ',' ',' ','o'}, 	/*06*/	{'o',' ','o',' ',' ',' ','o',' ',' ','o'}, 	/*07*/	{'o',' ','o','o','o',' ','o','o',' ','o'}, 	/*08*/	{'o','o',' ',' ',' ',' ',' ',' ',' ','o'}, 	/*09*/	{'o','o','o','o','o','o','o','o','o','o'} 	};  	print(map); 	walk(map, 1, 1);   	for (i = 0; i < MAP_X_SIZE; i++) 	{ 		for (j = 0; j < MAP_Y_SIZE; j++) 		{ 			if (walked[i][j] == 1) 			{ 				map[i][j] = '*'; 			} 		} 	} 	print(map);  	return 0;  }   void print (char map[MAP_X_SIZE][MAP_Y_SIZE])  {          int i, j;          for (i = 0; i < 10; i++)          {                  for (j = 0; j < 10; j++)                          printf ("%c", map[i][j]);                  printf ("\n");          }  }  int walk(char map[MAP_X_SIZE][MAP_Y_SIZE], int x, int y) { 	if ((map[x][y] != 'o') && walked[x][y] != 1) 	{ 		push(x, y); 		 		if ((8 == x) && (8 == y)) 		{ 			printf("PASSED!\n"); 			return OK_PASS; 		} 		 		if (OK_PASS == walk(map, x + 1, y)) 		{//DOWN 			return OK_PASS; 		} 		else if (OK_PASS == walk(map, x, y + 1)) 		{//RIGHT 			return OK_PASS; 		} 		else if (OK_PASS == walk(map, x - 1, y)) 		{//UP 			return OK_PASS; 		} 		else if (OK_PASS == walk(map, x, y - 1)) 		{//LEFT 			return OK_PASS; 		} 		else 		{//DEAD END 			pop(x, y); 			return NG_PASS; 		} 	} 	return NG_PASS;  }  void push(int x, int y) { 	step++; 	walked[x][y] = 1; }  void pop(int x, int y) { 	step--; 	walked[x][y] = 0; }