提交时间:2024-03-23 17:24:59

运行 ID: 139438

#include <bits/stdc++.h> using namespace std; int x[8] = {1,0,-1,0,1,-1,1,-1}; int y[8] = {0,1,0,-1,-1,1,-1,1}; int n,m,b[110][110]; char a[110][110]; int main() { ios::sync_with_stdio(0); memset(b,0,sizeof(b)); int n,m; cin >> n >> m; for(int i = 0;i < n;i++) for(int j = 0;j < m;j++) cin >> a[i][j]; for(int i = 0;i < n;i++) for(int j = 0;j < m;j++) for(int h = 0;h < 8;h++) if(a[i + x[h]][j + y[h]] == '*') b[i][j]++; for(int i = 0;i < n;i++) { for(int j = 0;j < n;j++) cout << b[i][j]; cout << '\n'; } }