POJ1979 DFS
来源:互联网 发布:mac速度慢怎么办 编辑:程序博客网 时间:2024/05/20 13:15
题目链接
#include<iostream>#include<stdio.h>using namespace std;#define N 100char map[N][N];int w, h;int dfs(int i, int j){ if (i >= 0 && i < h && j >= 0 && j < w) { if (map[i][j] == '#') { return 0; } map[i][j] = '#'; return 1 + dfs(i + 1, j) + dfs(i - 1, j) + dfs(i, j + 1) + dfs(i, j - 1); } return 0;}int main(){ // freopen("E:\input.txt", "r", stdin); int i, j; while (cin >> w >> h, w + h) { for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { //scanf("%c", &map[i][j]); cin >> map[i][j]; } } for (i = 0; i < h; i++) { for (j = 0; j < w; j++) { if (map[i][j] == '@') { cout << dfs(i, j) << endl; } } } } return 0;}
参考文章:
blog 1
0 0
- poj1979--DFS
- poj1979 DFS
- dfs--poj1979
- POJ1979 DFS
- poj1979 DFS
- POJ1979 DFS
- dfs-poj1979
- POJ1979 dfs
- poj1979 DFS
- poj1979-dfs
- poj1979【基础bfs/dfs】
- poj1979 BFS/DFS
- poj1979 dfs水题
- POJ1979迷宫问题DFS
- poj1979 Red and Black dfs
- poj1979 Red and Black(dfs)
- POJ1979 红与黑 DFS
- [dfs]poj1979 Red and Black
- Opencv的Rect类-矩形类
- 五岳归来不看山
- Introduction to Java Programming编程题7.11<硬币游戏:显示正反面>
- C++中 类 占 内存问题
- [leetcode-228]Summary Ranges(java)
- POJ1979 DFS
- CSU_1508_地图的四着色
- hdu 1808 Halloween treats 抽屉原理
- hdu 1808 Halloween treats 抽屉原理
- 自定义 URL Scheme 完全指南
- Opencv的Scalar类-颜色类
- 【Git分布式版本控制系统】远程仓库Github
- 字典树(Trie树、单词查找树、前缀树)
- 微服务-(1)