#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
int main()
{
char a[50][50]={
"####################",//x=0
"# # # #",//x=1
"# ## # # #### ## ###",//x=2
"# # # # #### ## ###",//x=3
"##O# # ###### ###",//x=4
"######## ###### ####",//x=5
"# ###$####### #",//x=6
"### ######## ###",//x=7
"####### ####### ##",//x=8
"## ## ## ### ##",//x=9
"## # ### # # # ##",//x=10
"## ####### #### ##",//x=11
"# # ### # ####",//x=12
"## ### #### # # ####",//x=13
"## ## # # #",//x=14
"#### ##### ## #### #",//x=15
"#### # ## # #",//x=16
"#### ########### # #",//x=17
"#### ####### #",//x=18
"########*###########" //x=19
};
int i,x,y,p,q;//x是x轴,y是y轴,p是终点x轴,q是终点y轴。
char ch;//每次输入
x=4; y=2; p=19; q=8;
for(i=0;i<=19;i++)
puts(a[i]);
while(x!=p||y!=q)
{
ch=getch();
if(ch=='x')
{
if(a[x+1][y]!='#')
{
a[x][y]=' ';
x++;
a[x][y]='O';
}
}
if(ch=='s')
{
if(a[x-1][y]!='#')
{
if(a[x-1][y] == '$')
{
a[16][8]=' ';
}
a[x][y]=' ';
x--;
a[x][y]='O';
}
}
if(ch=='z')
{
if(a[x][y-1]!='#')
{
a[x][y]=' ';
y--;
a[x][y]='O';
}
}
if(ch=='y')
{
if(a[x][y+1]!='#')
{
a[x][y]=' ';
y++;
a[x][y]='O';
}
}
system("cls");
for(i=0;i<=19;i++)
puts(a[i]);
}
system("cls");
printf("You win!\n");
Sleep(5000);
return 0;
}