文件名称:ma2
介绍说明--下载内容均来自于网络,请自行研究使用
显然求解骑士游历问题的每一步就是马在棋盘上走的一步。在每一步马需要选择一个方向进行游历,这时记住解的每一步需要记住两件事:
1.当前步的行列位置
2.当前步已经试探过哪些方向了,以便回溯回来时能够选择一个新的方向进行试探
所以使用两个数组,数组board记住棋盘的每个位置是在马的第几步到达的,这反映了问题的解,即第几步到哪个位置。数组direction记住在棋盘的某个位置已经试探过的方向,每个位置有八个方向,可按某种顺序对八个方向编号,然后在每个位置按编号顺序试探方向。 -Obviously the problem solving Knight traveled horse every step is a step on the board walk. At each step the horse needs to select a direction of travel, then the solution every step of the need to remember two things to remember: 1 current position Step 2 ranks the current step has sounded what direction, and come back when you can choose to back A new direction so that the use of two probe arrays, each array board remember the position of the board at the arrival of the horse steps, which reflects the solution of the problem, i.e., the position to which the first few steps. Remember array direction at a certain position of the board has been sounded in the direction of each location has eight directions, according to a certain order of eight directions number, then press the number sequence tentative direction at each location.
1.当前步的行列位置
2.当前步已经试探过哪些方向了,以便回溯回来时能够选择一个新的方向进行试探
所以使用两个数组,数组board记住棋盘的每个位置是在马的第几步到达的,这反映了问题的解,即第几步到哪个位置。数组direction记住在棋盘的某个位置已经试探过的方向,每个位置有八个方向,可按某种顺序对八个方向编号,然后在每个位置按编号顺序试探方向。 -Obviously the problem solving Knight traveled horse every step is a step on the board walk. At each step the horse needs to select a direction of travel, then the solution every step of the need to remember two things to remember: 1 current position Step 2 ranks the current step has sounded what direction, and come back when you can choose to back A new direction so that the use of two probe arrays, each array board remember the position of the board at the arrival of the horse steps, which reflects the solution of the problem, i.e., the position to which the first few steps. Remember array direction at a certain position of the board has been sounded in the direction of each location has eight directions, according to a certain order of eight directions number, then press the number sequence tentative direction at each location.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
ma2.cpp