#include "bits/stdc++.h" using namespace std; int dir[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{-1,-1},{1,-1},{-1,1}}; char s[55][55]; int n,m,a,b; int check(int x,int y){ int cnt = 0; for(int i=0;i<8;i++){ int tx = dir[i][0] + x; int ty = dir[i][1] + y; if(tx < 0 || ty < 0 || tx > n-1 || ty > m-1) continue; if(s[tx][ty] == 'M') cnt++; } return cnt; } void dfs(int x , int y){ s[x][y] = check(x,y) + '0'; if(s[x][y] != '0') return; for(int i=0;i<8;i++){ int tx = dir[i][0] + x; int ty = dir[i][1] + y; if(tx < 0 || ty < 0 || tx > n-1 || ty > m-1) continue; if(s[tx][ty] != 'E') continue; dfs(tx,ty); } } int main() { while (cin >> n >> m){ for(int i=0;i> s[i][j]; } } cin >> a >> b; if(s[a][b] == 'M') s[a][b]='X'; else dfs(a,b); for(int i=0;i 欢迎分享,转载请注明来源:内存溢出
赞
(0)
打赏
微信扫一扫
支付宝扫一扫
![微信扫一扫](/view/img/theme/weipay.png)
![支付宝扫一扫](/view/img/theme/alipay.png)
多态与友元学习(C++)大白话系列
上一篇
2022-12-17
(接上一篇)嵌入式C语言中关于运算符,ASCII码,标准C库中的IO函数,逗号运算符,三目运算符的定义和详细说明。
下一篇
2022-12-17
评论列表(0条)