文件名称:BaHuangHou
介绍说明--下载内容均来自于网络,请自行研究使用
题目:八皇后问题。
八皇后问题是指求解如何在国际象棋8*8棋盘上无冲突的放置八个皇后棋子。因为在国际象棋里,皇后的移动方式是横竖交叉,所以在任意一个皇后所在的位置的水平,竖直和斜45度都不能有其他棋子的存在。一个完整的无冲突的八皇后棋子分布成为八皇后问题的一个解。设计思路:我使用了回溯的方法来解决八皇后问题,也就是逐次试探的方法。这个方法是通过函数putchess()对自身的递归调用来实现的。运行程序后,主函数调用putchess()函数在棋盘第一行第一列上放置棋子,开始向下一行递归。每一步的递归中,首先检测待放位置有没有冲突出现,如果没有冲突,就放下棋子,并进入下一行递归,否则检测该行的下一个位置。如果整个一行中都没有可以放置的位置,就退回上一层递归。最后,如果本次放置成功,并且递归调用深度为7,就打印输出结果。-Title: Queen s eight questions.
Queen s eight questions refer to how to solve the 8* 8 chess board placed on the eight conflict-free Queen s pawn. Since at chess, the Queen of the mobile means are横竖cross, so at any one location s level, vertical and inclined 45 degrees can not have other pieces exist. A complete conflict-free distribution of the eight Queen s pawn to become queen eight questions a solution. Design ideas: I use a retrospective method to solve the eight Queen s question, that is, successive test method. This method is through the function putchess () recursive calls of their own to achieve. After running the program, the main function call putchess () function at the first line of the first column of the chessboard placed on a pawn down and his party start recursion. Every step of the recursion, the first question put Detect location appears there is no conflict, if there is no conflict, it is down a pawn, and into the next line recursive, otherwise detect the locatio
八皇后问题是指求解如何在国际象棋8*8棋盘上无冲突的放置八个皇后棋子。因为在国际象棋里,皇后的移动方式是横竖交叉,所以在任意一个皇后所在的位置的水平,竖直和斜45度都不能有其他棋子的存在。一个完整的无冲突的八皇后棋子分布成为八皇后问题的一个解。设计思路:我使用了回溯的方法来解决八皇后问题,也就是逐次试探的方法。这个方法是通过函数putchess()对自身的递归调用来实现的。运行程序后,主函数调用putchess()函数在棋盘第一行第一列上放置棋子,开始向下一行递归。每一步的递归中,首先检测待放位置有没有冲突出现,如果没有冲突,就放下棋子,并进入下一行递归,否则检测该行的下一个位置。如果整个一行中都没有可以放置的位置,就退回上一层递归。最后,如果本次放置成功,并且递归调用深度为7,就打印输出结果。-Title: Queen s eight questions.
Queen s eight questions refer to how to solve the 8* 8 chess board placed on the eight conflict-free Queen s pawn. Since at chess, the Queen of the mobile means are横竖cross, so at any one location s level, vertical and inclined 45 degrees can not have other pieces exist. A complete conflict-free distribution of the eight Queen s pawn to become queen eight questions a solution. Design ideas: I use a retrospective method to solve the eight Queen s question, that is, successive test method. This method is through the function putchess () recursive calls of their own to achieve. After running the program, the main function call putchess () function at the first line of the first column of the chessboard placed on a pawn down and his party start recursion. Every step of the recursion, the first question put Detect location appears there is no conflict, if there is no conflict, it is down a pawn, and into the next line recursive, otherwise detect the locatio
(系统自动生成,下载前可以参看下载内容)
下载文件列表
BaHuangHou
..........\大作业4.cpp
..........\大作业4.exe
..........\大作业4.txt
..........\大作业4.cpp
..........\大作业4.exe
..........\大作业4.txt