文件名称:migong
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:1.35kb
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
数据结构堆栈的经典应用:
/*一:迷宫问题用堆栈的方法:
求迷宫中一条从入口到出口的路径的算法可简单描述如下:
设定当前位置的初值为入口位置:
do{
若当前位置可通,
则{ 将当前位置插入堆栈顶
若该位置是出口位置,则结束
否则切换当前位置的东邻块为新的当前位置
}
否则,
若堆栈不空且栈顶位置尚有其他方向未经探索
则设定新的当前位置为沿顺时针方向转到的栈顶位置的下一相邻块
若栈不空但栈顶位置的四周均不可通,
则{删去栈顶位置
若栈不空,则重新测试新的栈顶位置,
直至找到一个可通的相邻或出栈至栈空
}
}(栈不空)*/-Classic application of the data structure stack:
/* A: maze problem with the stack:
Seeking an entrance to the exit in the maze path algorithm can be described as follows:
Set the initial value of the current location of the entrance location:
do {
If the current location through
Then {the current position into the top of the stack
If the location is the export position, the end
Otherwise, switch the current location of the east block for the new current position
}
Otherwise, the
If the stack is not empty and the stack position that there are other directions unexplored
Set a new current position clockwise to the top of the stack location of the next adjacent block
If the stack is not empty but the top of the stack around the location of the incommensurability
{By deleting the top of the stack location
If the stack is not empty, then re-test the new stack location
Until you find a pass adjacent to the stack
/*一:迷宫问题用堆栈的方法:
求迷宫中一条从入口到出口的路径的算法可简单描述如下:
设定当前位置的初值为入口位置:
do{
若当前位置可通,
则{ 将当前位置插入堆栈顶
若该位置是出口位置,则结束
否则切换当前位置的东邻块为新的当前位置
}
否则,
若堆栈不空且栈顶位置尚有其他方向未经探索
则设定新的当前位置为沿顺时针方向转到的栈顶位置的下一相邻块
若栈不空但栈顶位置的四周均不可通,
则{删去栈顶位置
若栈不空,则重新测试新的栈顶位置,
直至找到一个可通的相邻或出栈至栈空
}
}(栈不空)*/-Classic application of the data structure stack:
/* A: maze problem with the stack:
Seeking an entrance to the exit in the maze path algorithm can be described as follows:
Set the initial value of the current location of the entrance location:
do {
If the current location through
Then {the current position into the top of the stack
If the location is the export position, the end
Otherwise, switch the current location of the east block for the new current position
}
Otherwise, the
If the stack is not empty and the stack position that there are other directions unexplored
Set a new current position clockwise to the top of the stack location of the next adjacent block
If the stack is not empty but the top of the stack around the location of the incommensurability
{By deleting the top of the stack location
If the stack is not empty, then re-test the new stack location
Until you find a pass adjacent to the stack
(系统自动生成,下载前可以参看下载内容)
下载文件列表
迷宫1.cpp
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.