#include <iostream>
#include <iomanip>
#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++){
if(i<10)cout<<setw(2)<<0<<i;
else if(i==10) cout<<" "<<setw(2)<<i<<" ";
else cout<<setw(2)<<i<<" ";
}
cout<<endl;
for(int i=1; i<=lie; i++) {
cout<<setw(2)<<i<<" ";
for(int j=1; j<=hang; j++) {
if(wan[i][j]==0) {
cout<<setw(3)<<"O ";
} else if( (i>=shenglilie-0 && i<=shenglilie+0) && (j>=shenglihang-0 && j<=shenglihang+0) ) {
cout<<setw(3)<<"P ";
} else if( (i>=shenglilie-1 && i<=shenglilie+1) && (j>=shenglihang-1 && j<=shenglihang+1) ) {
cout<<setw(3)<<"N ";
} else if( (i>=shenglilie-2 && i<=shenglilie+2) && (j>=shenglihang-2 && j<=shenglihang+2) ) {
cout<<setw(3)<<"Z ";
} else {
cout<<setw(3)<<"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<20 and 0<b<20"<<endl;
cin>>hang>>lie;
shenglihang=rand()%hang+1;
shenglilie=rand()%lie+1;
if(hang<=19&&lie<=19&&hang>0&&lie>0)dayin=true;
if(dayin)shengcheng();
else {
cout<<"a<20,b<20";
return 0;
}
while(!win) {
kaishi();
shengcheng();
}
cout<<"\n\n\nwin!!!\n\n\n"<<"time:"<<cishu;
return 0;
}