#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
char cnt[a][b];
int t=0;
for(int i=0;i<a;i++)
for(int j=0;j<b;j++)
cin>>cnt[i][j];
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
{
t=0;
if(cnt[i][j]=='*')
cout<<"*";
else if(cnt[i][j]=='?')
{
for(int k=i-1;k<=i+1;k++)
for(int l=j-1;l<=j+1;l++)
if(!(k<0 || l<0))
if(cnt[k][l]=='*')
t++;
cout<<t;
}
}
cout<<endl;
}
return 0;
}
想法是遍历周围8个点,寻找是否有地雷,有则++