文件名称:1.10queen
介绍说明--下载内容均来自于网络,请自行研究使用
要解决N皇后问题,其实就是要解决好怎么放置这n个皇后,每一个皇后与前面的所有皇后不能在同一行、同一列、同一对角线,在这里我们可以以行优先,就是说皇后的行号按顺序递增,只考虑第i个皇后放置在第i行的哪一列,所以在放置第i个皇后的时候,可以从第1列判断起,如果可以放置在第1个位置,则跳到下一行放置下一个皇后。如果不能,则跳到下一列...直到最后一列,如果最后一列也不能放置,则说明此时放置方法出错,则回到上一个皇后向之前放置的下一列重新放置。此即是回溯法的精髓所在。当第n个皇后放置成功后,即得到一个可行解,此时再回到上一个皇后重新放置寻找下一个可行解...如此后,即可找出一个n皇后问题的所有可行解。-To solve the N queens problem, in fact, is to solve how to place the n queens, each in front of the Queen and the Queen is not all on the same line, same column, the same diagonal, where we can line a priority, that the Queen The line number increment sequentially, considering only the i-th place in Queens which i-th row of columns, so in the first place when i queens can be judged from the first one since, if one can be placed in the first position, Jump to the next line to place the next queen. If not, skip to the next column ... until the last one, the last one if it can not be placed, then the wrong placement method at this time, then back to a queen to be placed before the next column repositioning. Namely, is the essence of backtracking. After the success of the n-queens place that gets a feasible solution, then go back to a queen relocate to find the next feasible solution ... so, you are ready to find an n-queens problem for all feasible solutions.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
1.10皇后问题
............\check.cpp
............\input.txt
............\main.cpp
............\output.txt
............\queen.cbp
............\queen.h
............\queen.layout
............\思想.txt