文件名称:migong
介绍说明--下载内容均来自于网络,请自行研究使用
数据结构堆栈的经典应用:
/*一:迷宫问题用堆栈的方法:
求迷宫中一条从入口到出口的路径的算法可简单描述如下:
设定当前位置的初值为入口位置:
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