文件名称:8huanghou
介绍说明--下载内容均来自于网络,请自行研究使用
算法流程:
1、数据初始化。
2、从n列开始摆放第n个皇后(因为这样便可以符合每一竖列一个皇后的要求),先测试当前位置(n,m)是否等于0(未被占领):
如果是,摆放第n个皇后,并宣布占领(记得要横列竖列斜列一起来哦),接着进行递归;
如果不是,测试下一个位置(n,m+1),但是如果当n<=8,m=8时,却发现此时已经无法摆放时,便要进行回溯。
3、当n>8时,便一一打印出结果。
优点:逐一测试标准答案,不会有漏网之鱼。
-Algorithm processes: 1, data initialization. 2, from n to start out the first n-place Queen s (because it would be able to meet each vertical column of a Queen s request), first test the current position (n, m) is equal to 0 (not occupied): If yes, before let the first n of Queen s, and announced that the occupation (remember to put out oblique row out together Oh), followed by recursive If not, test the next location (n, m+ 1), but if n <= 8, m = 8, they found that at this time have been unable to display, it should be retroactive. 3, when n> 8, they all print out the results. Advantages: one by one testing standard answer, there will not be falling through the openings.
1、数据初始化。
2、从n列开始摆放第n个皇后(因为这样便可以符合每一竖列一个皇后的要求),先测试当前位置(n,m)是否等于0(未被占领):
如果是,摆放第n个皇后,并宣布占领(记得要横列竖列斜列一起来哦),接着进行递归;
如果不是,测试下一个位置(n,m+1),但是如果当n<=8,m=8时,却发现此时已经无法摆放时,便要进行回溯。
3、当n>8时,便一一打印出结果。
优点:逐一测试标准答案,不会有漏网之鱼。
-Algorithm processes: 1, data initialization. 2, from n to start out the first n-place Queen s (because it would be able to meet each vertical column of a Queen s request), first test the current position (n, m) is equal to 0 (not occupied): If yes, before let the first n of Queen s, and announced that the occupation (remember to put out oblique row out together Oh), followed by recursive If not, test the next location (n, m+ 1), but if n <= 8, m = 8, they found that at this time have been unable to display, it should be retroactive. 3, when n> 8, they all print out the results. Advantages: one by one testing standard answer, there will not be falling through the openings.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
8huanghou.txt