dfs
来源:互联网 发布:excel粘贴数据空白 编辑:程序博客网 时间:2024/04/30 21:43
采用栈的结构实现:
void dfs(point start)
{point next,tem;
stack<point>q;//建栈,最好写在函数里面
q.push(start);//入栈
while(!q.empty())
{
tem=q.top();//提取栈顶元素
if(tem.x==m&&tem.y==n)//处理过程
{
ok=1;
return ;
}
q.pop();//处理过后出栈
v[tem.x][tem.y]=1//标记已被访问
;
for(int i=0;i<4;i++)//访问四周的点,访问不仅限于四周,具体情况具体分析。{
next.x=tem.x+x[i],next.y=tem.y+y[i];
if(inmap(next)&&a[next.x][next.y]&&!v[next.x][next.y])//满足条件则入栈
q.push(next);
}
}
- DFS
- DFS
- dfs
- dfs
- dfs
- dfs
- DFS
- DFS
- dfs
- DFS
- DFS
- DFS
- dfs
- DFS
- dfs
- dfs
- dfs
- dfs
- MySQL中varchar最大长度是多少?
- 操作配置文件的一种设计思路
- String类的包装 ---- 类声明
- 网上支付心得1-网上支付内容分析
- ScrollView基础
- dfs
- String类的包装 ---- 类实现
- Android 开发中使用 SQLite 数据库
- NSURLConnection同步下载和异步下载
- Linux内核的Nand驱动流程分析
- Wireshark图解教程(简介、抓包、过滤器)
- JBoss5.1.0配置
- 基于Tiny C compiler的c脚本混合编程方法
- 理解Xen的network-bridge模式