2011-05-24 22:57:12 n皇后问题6_6 测试数据 10 1 2 3 4 5 6 7 8 9 10 11 12 13 分支限界法 与广度优先的最大差别在于father.checkNext(i)剪枝函数会检测是否可进入下一个节点,如果不可进入,则后续的所有排列均不搜索 //Author:王子硕 Date:2011/5/24 //Description:经典n皇后问题 广度优先 建议n<=14 #include <iostream> #include <fstream> #include <algorithm> #include <functional> #include <queue> using namespace std; ifstream in("input.txt"); ofstream out("output.txt"); class Node{ public: Node(int n){ t = 0; this->n = n; loc = new int[n + 1]; for (int i = 0; i<= n; ++i) { loc[i] = 0; } } Node(const Node &other){ this->t = other.t; this->n = other.n; this->loc = new int [n + 1]; for (int i = 0; i <= n; ++i){