#include <cstdio>
#include <windows.h>
#include <conio.h>
//8*12 走迷宫
//0=黑色1=蓝色2=绿色3=湖蓝色4=红色5=紫色6=黄色
//7=白色8=灰色9=淡蓝色A=淡绿色B=淡浅绿色C=淡红色D=淡紫色E=淡黄色F=亮白色
char a[50][50]={"|##########|",
"|O ## ##|",
"|# # ### ##|",
"|# ### #|",
"|# # ## #|",
"|## ## ## ",
"|## ###|",
"|##########|"};
int main()
{
system("color 3D");
int x=1,y=1;
char ch;
for(int i=0;i<=7;i++)
puts(a[i]);
while(1)
{
ch=getch();
if(ch=='s')//下
{
if(a[x+1][y]==' ')
{
a[x][y]=' ';
x++;
a[x][y]='O';
}
}
else if(ch=='w')//上
{
if(a[x-1][y]==' ')
{
a[x][y]=' ';
x--;
a[x][y]='O';
}
}
else if(ch=='a')//左
{
if(a[x][y-1]==' ')
{
a[x][y]=' ';
y--;
a[x][y]='O';
}
}
else if(ch=='d')//右
{
if(a[x][y+1]==' ')
{
a[x][y]=' ';
y++;
a[x][y]='O';
}
}
system("cls");
for(int i=0;i<=7;i++)
puts(a[i]);
if(x==5 && y==11)
break;
}
printf("你赢了!");
Sleep(10000);
return 0;
}
10-14
233
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-11
3760
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-05
59
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-07