ZWJZWJ 2023-08-13 14:20:59
点我顶贴
收藏
删除
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,a[110][110];
char c;
int main(){
cin>>n>>m;
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
cin>>c;
if(c=='*'){
a[i][j]=INT_MIN;
a[i-1][j-1]++;
a[i-1][j]++;
a[i-1][j+1]++;
a[i][j-1]++;
a[i][j+1]++;
a[i+1][j-1]++;
a[i+1][j]++;
a[i+1][j+1]++;
}
}
}
for(i=1;i<=n;i++){
for(j=1;j<=m;j++){
if(a[i][j]<0){
cout<<'*';
}else{
cout<<a[i][j];
}
}
cout<<endl;
}
}