Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
469 | 关清声 | 扫雷游戏 | C++ | Wrong Answer | 0 MS | 260 KB | 1025 | 2022-08-22 09:55:16 |
#include<iostream> using namespace std; int main() { int n,m; char a[101][101]={0}; cin>>n>>m; for(int i=1;i<=n;i++) { for(int l=1;l<=m;l++) { cin>>a[i][l]; } } for(int i=1;i<=n;i++) { for(int l=1;l<=m;l++) { if(a[i][l]!='*') { a[i][l]='0'; } } } for(int i=1;i<=n;i++) { for(int l=1;l<=m;l++) { if(a[i-1][l]=='*'&&a[i][l]!='*') { a[i][l]++; } if(a[i+1][l]=='*'&&a[i][l]!='*') { a[i][l]++; } if(a[i][l-1]=='*'&&a[i][l]!='*') { a[i][l]++; } if(a[i][l+1]=='*'&&a[i][l]!='*') { a[i][l]++; } if(a[i-1][l+1]=='*'&&a[i][l]!='*') { a[i][l]++; } if(a[i-1][l-1]=='*'&&a[i][l]!='*') { a[i][l]++; } if(a[i+1][l+1]=='*'&&a[i][l]!='*') { a[i][l]++; } if(a[i+1][l-1]=='*'&&a[i][l]!='*') { a[i][l]++; } } } for(int i=1;i<=n;i++) { for(int l=1;l<=m;l++) { cout<<a[i][l]<<" "; } cout<<endl; } return 0; }
------Input------
5 5 ???*? *???* ????? ????* ?*??*
------Answer-----
111*2 *112* 11022 1112* 1*12*
------Your output-----
1 1 1 * 2 * 1 1 2 * 1 1 0 2 2 1 1 1 2 * 1 * 1 2 *