检索规则说明:AND代表“并且”;OR代表“或者”;NOT代表“不包含”;(注意必须大写,运算符两边需空一格)
检 索 范 例 :范例一: (K=图书馆学 OR K=情报学) AND A=范并思 范例二:J=计算机应用与软件 AND (U=C++ OR U=Basic) NOT M=Visual
作 者:程元斌[1]
机构地区:[1]江汉大学数学与计算机科学学院
出 处:《计算机系统应用》2013年第10期147-150,共4页Computer Systems & Applications
摘 要:迄今为止,已有多种基于不同理论的八皇后问题算法.本文提出一种类似筛法的新算法:在棋盘某一格放上一个皇后的同时划去经过这一格的纵、横、及正负45度线上的所有格位,或者说筛去这些格位;后来的皇后只能放在未被占据或划去的格位上;若所有的皇后都能放入一个格位,则得到了一个布局或一个解.依据这种思路容易制定一个N皇后问题的简洁算法.实验结果表明,筛法算法的效率大大高于经典的回溯法.So far, there have been many different algorithm of eight queens problem. A similar sieve algorithm is presented in this paper: Using a algorithm similar to the sieve method in number theory: place the first queen in the first grid of the first row, and mark out the row, the column, the downward diagonal and the upward diagonal through the first queen; then place the second queen on the most left grid of the unmarked grid of the second row, and mark out the row, the column, the downward diagonal and the upward diagonal through the second queen; like this, queens are added, one by one. if all the queens can be placed on the board, a layout or a solution received. Traversing all grids of all row, we would get all solutions of N-queens problem. Based on the simple idea, we can develop a N-queens program easily. The experimental results show that the efficiency of the sieve program is much higher than the classic backtracking program.
分 类 号:TP301.6[自动化与计算机技术—计算机系统结构]
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在载入数据...
正在链接到云南高校图书馆文献保障联盟下载...
云南高校图书馆联盟文献共享服务平台 版权所有©
您的IP:216.73.216.117