#include<iostream>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
const int N=1005;
int main(){
int n,m;
int shape1[102][102];
char shape2[102][102];
cin>>n>>m;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
shape1[i][j]=0;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>shape2[i][j];
if(shape2[i][j]=='*'){//start |if|
shape1[i+1][j+1]++;
shape1[i][j+1]++;
shape1[i-1][j+1]++;
shape1[i+1][j]++;
//shape1[i][j];
shape1[i-1][j]++;
shape1[i+1][j-1]++;
shape1[i][j-1]++;
shape1[i-1][j-1]++;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(shape2[i][j]=='*'){
cout<<"*";
}else{
cout<<shape1[i][j];
}
}
cout<<endl;
}
return 0;
}
}
<fontsize=1000>20求助</font>