Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
40513 lnx 扫雷游戏地雷数计算 C++ 解答错误 0 MS 244 KB 876 2024-02-11 21:34:58

Tests(0/1):


#include<iostream> using namespace std; int main() { int n,m; cin>>n>>m; char in[n][m],out[n][m]; for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ cin>>in[i][j]; //printf("%c\n",in[i][j]); } } for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ if (in[i][j]=='*'){ out[i][j] = '*'; } else { int count=0; int start_line = i-1; if (i==0) start_line=i; int end_line = i+1; if (i==n-1) end_line=i; int start_col=j-1; if (j==0) start_col=j; int end_col = j+1; if (j==m-1) end_col=j; for (int x=start_line;x<=end_line;x++){ for (int y=start_col;y<=end_col;y++){ if (x==i &&y==j) continue; if (in[x][y] == '*') count++; } } out[i][j]=(char)(count+48); } cout<<out[i][j]; if (j<m-1) cout<<" "; else if (i<n-1) cout<<"\n"; } } }


测评信息: