新手天翼
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<conio.h>
using namespace std;
int main()
{
int x=7,y=2,q=1;
char ch;
int a[10][30]{{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,0,1,0,1,1,1,0,0,0,0,1},
{1,0,0,3,0,0,3,0,0,0,0,1,0,1,0,1,0,0,0,0,1,1,1,0,0,0,0,0,0,1},
{1,3,3,3,0,0,3,3,3,0,0,1,0,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0},
{1,0,0,3,0,0,3,0,0,0,0,1,0,1,0,1,0,0,0,0,0,0,0,0,1,0,1,0,0,0},
{1,0,0,3,3,3,3,0,0,0,0,1,0,1,0,1,0,0,0,1,1,1,1,1,1,0,1,0,0,0},
{1,0,9,0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,1},
{1,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,0,1},
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};
int i,j;
while(q==1){
for(i=0;i<=9;i++)
{
for(j=0;j<=29;j++)
{
if(a[i][j]==1)
{
cout<<"OT";
}
else if(a[i][j]==0)
cout<<" ";
else if(a[i][j]==3)
cout<<"Y ";
else if(a[i][j]==9)
{
cout<<"@ ";
}
else if(a[i][j]==8)
{
cout<<" ";
}
}
cout<<endl;
}
ch=getch();
if( ch == 'a'&&a[x][y-1]!=1)
{
a[x][y-1]=9;
a[x][y]=0;
y-=1;
system("cls");
}
else if(ch=='w'&&a[x-1][y]!=1)
{
a[x-1][y]=9;
a[x][y]=0;
x-=1;
system("cls");
}
else if(ch=='s'&&a[x+1][y]!=1)
{
a[x+1][y]=9;
a[x][y]=0;
x+=1;
system("cls");
}
else if(ch=='d'&&a[x][y+1]!=1)
{
a[x][y+1]=9;
a[x][y]=0;
y+=1;
system("cls");
if(x==2&&y==2)
{
q=2;
cout<<"通关!";
for(int j=1;j<=1000000000;j++)
{
int f,g;
f=g;
}
system("cls");
}
}
else
{
system("cls");
}
} return 0;
}