提交时间:2024-03-31 17:35:54
运行 ID: 140816
#include<bits/stdc++.h> using namespace std; int b[105][105]; int main() { int m,n; string 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++) { cin>>o; for(int j=2;j<=n+1;j++) { if(o[j-2]=='*') { b[i][j]=-99; 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=3;i<=m+1;i++) { for(int j=2;j<=n+1;j++) { if(b[i][j]<0) { cout<<"*"; } else { cout<<b[i][j]; } } cout<<endl; } return 0; }