AcWing 462. 扫雷游戏
原题链接
简单
作者:
97265
,
2019-07-31 14:52:08
,
所有人可见
,
阅读 802
#include<iostream>
using namespace std;
const int A=110;
char place[A][A];
int main()
{
int a,b;
cin>>a>>b;
for(int i=1;i<=a;i++)
{
for(int j=1;j<=b;j++)
cin>>place[i][j];
}
for(int i=1;i<=a;i++)
{
for(int j=1;j<=b;j++)
{
if(place[i][j]=='*') cout<<"*";
else
{
int c=0;
if(place[i][j-1]=='*') c++;
if(place[i][j+1]=='*') c++;
if(place[i-1][j]=='*') c++;
if(place[i+1][j]=='*') c++;
if(place[i+1][j+1]=='*') c++;
if(place[i-1][j+1]=='*') c++;
if(place[i+1][j-1]=='*') c++;
if(place[i-1][j-1]=='*') c++;
cout<<c;
}
}
cout<<endl;
}
return 0;
}