简单的迷宫代码如下:
#include#include #include #include #include using namespace std; char maze[15][19]={ //初始化 " ",//0 "######## #########",//1 "## # ### #",//2 "## ##### # #### ##",//3 "## # # # # #",//4 "# ##### # ##",//5 "# # # #",//6 "# ## ### # # #",//7 "## # # # #",//8 "## # ##### ####",//9 "## # #### ###",//10 "## # ## ##",//11 "#### ### ### # #",//12 "### # # ##",//13 "##################",//14 }; int main() { srand(time(0)); int x,y,i,j,cnt=0; char c; do { x=rand()%14+1; y=rand()%19; } while(maze[x][y]=='#'); maze[x][y]='i'; for(i=1;i<15;i++,cout< c=getch(); cnt++; system("cls"); if(c=='w'){ maze[x][y]=' '; x--; if(maze[x][y]=='#') x++; maze[x][y]='i'; } else if(c=='s') { maze[x][y]=' '; x++; if(maze[x][y]=='#') x--; maze[x][y]='i'; } else if(c=='a') { maze[x][y]=' '; y--; if(maze[x][y]=='#') y++; maze[x][y]='i'; } else if(c=='d') { maze[x][y]=' '; y++; if(maze[x][y]=='#') y--; maze[x][y]='i'; } else { } for(i=1;i<15;i++,cout<



