#include <iostream>
#include <windows.h>
#include <time.h>
#define endl "\n"
using namespace std;
int hang,lie,wan[105][105]= {0},cishu,heng,shu,shenglihang,shenglilie;
bool dayin=0,win=0;
void shengcheng() {
system("cls");
cout<<" ";
for(int i=1; i<=hang; i++)cout<<i<<" ";
cout<<endl;
for(int i=1; i<=lie; i++) {
cout<<i<<" ";
for(int j=1; j<=hang; j++) {
if(wan[i][j]==0) {
cout<<"O ";
} else if( (i>=shenglilie-0 && i<=shenglilie+0) && (j>=shenglihang-0 && j<=shenglihang+0) ) {
cout<<"P ";
} else if( (i>=shenglilie-1 && i<=shenglilie+1) && (j>=shenglihang-1 && j<=shenglihang+1) ) {
cout<<"N ";
} else if( (i>=shenglilie-2 && i<=shenglilie+2) && (j>=shenglihang-2 && j<=shenglihang+2) ) {
cout<<"Z ";
} else {
cout<<"X ";
}
}
cout<<endl;
}
return ;
}
void kaishi() {
cishu++;
cout<<"Z:周围2格,N:周围1格"<<endl;
cout<<"输入:列 行\n ";
cin>>heng>>shu;
if(heng<1 || heng>hang || shu<1 || shu>lie) {
cout<<"false!"<<endl;
cishu--;
Sleep(500);
return;
}
if(wan[shu][heng]>0) {
cout<<"false!"<<endl;
cishu--;
Sleep(500);
return;
}
wan[shu][heng]++;
if(heng==shenglihang&&shu==shenglilie) {
win=1;
return ;
}
}
int main() {
srand(time(0));
cout<<"0<a<10 and 0<b<10"<<endl;
cin>>hang>>lie;
shenglihang=rand()%hang+1;
shenglilie=rand()%lie+1;
if(hang<=10&&lie<=10&&hang>0&&lie>0)dayin=true;
if(dayin)shengcheng();
else {
cout<<"a<10,b<10";
return 0;
}
while(!win) {
kaishi();
shengcheng();
}
cout<<"\n\n\nwin!!!\n\n\n"<<"time:"<<cishu;
return 0;
}