Lake Counting POJ
来源:互联网 发布:不教翠羽遇萧峰 知乎 编辑:程序博客网 时间:2024/04/29 00:56
简单dfs
求有几块水
#include <cstdio>#include <algorithm>using namespace std;int n,m,num;char mp[110][110];void dfs(int x,int y) {if (x<0 || y<0 || x>=n || y>=m) return;if (mp[x][y]=='.') return;mp[x][y]='.';for (int dx=-1;dx<=1;dx++) { //八方向的写法 for (int dy=-1;dy<=1;dy++) {dfs(x+dx,y+dy);}} return;}int main(){while (~scanf ("%d%d",&n,&m)) {for (int i=0;i<n;i++) scanf ("%s",mp[i]);num=0;for (int i=0;i<n;i++) {for (int j=0;j<m;j++) {if (mp[i][j]=='W') {num++;dfs(i,j);}}}printf ("%d\n",num);}return 0;}
0 0
- poj 2386 Lake Counting
- poj 2386 Lake Counting
- POJ 2386 Lake Counting
- poj 2386 Lake Counting
- poj 2386 Lake Counting
- poj 2386 Lake Counting
- POJ 2386 Lake Counting
- Poj 2358 Lake Counting
- poj 2386 Lake Counting
- POJ 2386 Lake Counting
- POJ 2386 Lake Counting
- poj 2386 Lake Counting
- POJ - Lake Counting(DFS)
- POJ 2386 Lake Counting
- POJ 2386 Lake Counting
- POJ-2386-Lake Counting
- POJ 2386 Lake Counting
- poj 2386 Lake Counting
- css盒模型和定位
- 独木舟上的旅行
- MySQL性能优化
- 使用QuartZ定时发送邮件
- 三洋献瑞
- Lake Counting POJ
- 数据库三大范式详解(通俗易懂)
- Ubuntu服务器入门指南
- 混合开启服务
- nyoj 1187 模拟2048
- MySQL命令(详细)
- 501. Find Mode in Binary Search Tree\492. Construct the Rectangle\*486. Predict the Winner\输出一个level
- 操作系统各大知识模块
- Sql Server查询语句