提交时间:2024-03-25 20:47:24
运行 ID: 139792
#include<bits/stdc++.h> using namespace std; int n; int m; char c; bool b[110][110]; int main() { cin>>n; cin>>m; for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { cin>>c; b[i][j]=(c=='*' ? 1 : 0); } } for(int i=1;i<=n;i++) { for(int j=1;j<=m;j++) { (b[i][j]==1 ? cout<<"*" : cout<<b[i-1][j-1]+b[i-1][j]+b[i-1][j+1]+b[i][j-1]+b[i][j]+b[i][j+1]+b[i+1][j-1]+b[i+1][j]+b[i+1][j+1]); } cout<<endl; } return 0; }