Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
51293 | littletwleve | 扫雷游戏地雷数计算 | C++ | Accepted | 0 MS | 252 KB | 620 | 2024-09-20 17:02:11 |
#include<bits/stdc++.h> using namespace std; char d[110][110]; int main(){ int n,m; cin>>n>>m; for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++) cin>>d[i][j]; } for(int i=1;i<=n;i++){ for(int j=1;j<=m;j++){ if(d[i][j]=='*') cout<<'*'; else{ int count=0; if(d[i-1][j]=='*') count++; if(d[i+1][j]=='*') count++; if(d[i][j-1]=='*') count++; if(d[i][j+1]=='*') count++; if(d[i-1][j-1]=='*') count++; if(d[i+1][j-1]=='*') count++; if(d[i-1][j+1]=='*') count++; if(d[i+1][j+1]=='*') count++; cout<<count; } } cout<<endl; } return 0; }