DFS算法
来源:互联网 发布:python 列表内元组 编辑:程序博客网 时间:2024/05/14 08:30
voiddfs (int step)
{
判断边界
尝试每一种可能for (i = 1;i < n;i++)
{
book[i]==1; //处理前标记下一个节点
继续下一步dfs (step+1);
book[i]==0; //还原处理过的节点,以进行下一次尝试
}
返回
}
打印路径---DFS---栈
用数组实现栈,先进后出
struct node
{
int x;
int y;
}
struct node s[256];
int top;
void dfs(int x,int y,int front)//front 进水管方向
{
{
int x;
int y;
}
struct node s[256];
int top;
void dfs(int x,int y,int front)//front 进水管方向
{
//判断是否已经到终点
if(x==n && y==m+1)
{
flag=1;
for(int i=1;i<=top;++i)
{
printf("%d %d",s[i].x,s[j].y)
if(x==n && y==m+1)
{
flag=1;
for(int i=1;i<=top;++i)
{
printf("%d %d",s[i].x,s[j].y)
}
return;
}
}
//判断是否越界
book[x][y]=true;
top++;
s[top].x=x;
s[top].y=y;
......
book[x][y]=false;//取消标记
top--;//当前方块出栈
book[x][y]=true;
top++;
s[top].x=x;
s[top].y=y;
......
book[x][y]=false;//取消标记
top--;//当前方块出栈
}
0 0
- DFS算法
- DFS 算法
- DFS算法
- DFS算法
- dfs算法
- DFS算法
- DFS算法
- DFS算法
- dfs算法
- 非递归dfs算法
- {数据结构}DFS算法
- 非递归dfs算法
- poj1014--贪心算法,dfs
- 非递归dfs算法
- dfs深度优先算法
- BFS和DFS算法
- 算法入门之DFS
- BFS和DFS算法
- 元对象系统
- java基础知识总结(绝对经典)
- Android Studio 导入第三方jar包的正确姿势
- gsmhack
- nagios系列(一)centos6.5环境部署nagios服务端
- DFS算法
- HDOJ 2067 小兔的棋盘(棋盘dp)
- go利用x/net/html包实现的蜘蛛
- spring boot
- OC中调用JS
- HDU 1194
- 如何保存Win10壁纸
- Data Type
- 面试题:较为完整的atoi的实现,奶牛苹果的最小搬运次数