【文件属性】:
文件名称:n皇后问题的求解答案
文件大小:28KB
文件格式:DOC
更新时间:2014-07-26 06:35:45
N皇后
#include
#include
using namespace std;
void backtrack(int, vector, int, int);
bool place(int, vector);
void displayqueen(vector, int, int);
int sum = 0;
int main(void)
{
int N;
int kind;
cout<<"请输入皇后的个数:";
cin>>N;
vector x(N+1,0);
cout<<"----------------------------------"<>kind;
backtrack(1, x, N, kind);
return 0;
}
void backtrack(int t, vector x, int N, int kind)
{
if(t > N)
{
sum += 1;
displayqueen(x, N, kind);
}
else
{
for(int i=1; i x)
{
for(int j=1; j x, int N, int kind)
{
if(kind == 1)
{
cout<<"第"< > S(N+1, vector(N+1));
for(int i=1; i