提交时间:2024-03-31 17:29:42
运行 ID: 140809
#include<bits/stdc++.h> using namespace std; int b[105][105]; int main() } int m,n; srting o; cin>>m>>n; for(int i=1;i<=m+2;i++) { for(int j=1;j<=n+2;j++) { b[i][j]=0; } } for(int i=2;i<=m+1;i++) { getline(cin,o); for(int j=2;j<=n+1;j++) { if(o[j-2]=='*') { b[i][j]=-9; b[i+1][j]++; b[i-1][j]++; b[i+1][j-1]++; b[i-1][j-1]++; b[i+1][j+1]++; b[i-1][j+1]++; b[i][j-1]++; b[i][j+1]++; } } } for(int i=2;i<=m+1;i++) { for(int j=2;j<=n+1;j++) { if(b[i][j]==-1) { cout<<"*"; } else { cout<<b[i][j]; } } cout<<endl; } return 0; }