10 条题解
-
2
#include <bits/stdc++.h> using namespace std; int a,b,c[114][114]; string s[114]; int main(){ cin >> a >> b; for(int i = 0 ; i < a ; i++) cin >> s[i]; for(int i = 0 ; i < a ; i++){ for(int j = 0 ; j < b ; j++){ if(s[i][j] == '*'){ c[i][j] = -114514; if(i == 0){ if(j == 0) c[i+1][j]++,c[i+1][j+1]++,c[i][j+1]++; else c[i][j-1]++,c[i+1][j-1]++,c[i+1][j]++,c[i+1][j+1]++,c[i][j+1]++; } else{ if(j == 0) c[i-1][j]++,c[i-1][j+1]++,c[i+1][j]++,c[i+1][j+1]++,c[i][j+1]++; else c[i-1][j-1]++,c[i][j-1]++,c[i+1][j-1]++,c[i+1][j]++,c[i+1][j+1]++,c[i][j+1]++,c[i-1][j]++,c[i-1][j+1]++; } } } } for(int i = 0 ; i < a ; i++){ for(int j = 0 ; j < b ; j++){ if(c[i][j] < 0) cout << "*"; else cout << c[i][j]; } cout << endl; } return 0; }
信息
- ID
- 749
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 4
- 标签
- 递交数
- 347
- 已通过
- 154
- 上传者