N 皇后问题,回溯
#include<stdio.h>#include<math.h>
#define N_QUEENS 10
int x[8];
bool place(int k)
{
int i;
for(i=1;i<k;i++)
if(x[k]==x[i]||abs(k-i)==abs(x[k]-x[i]))
return false;
return true;
}
void queue(int n)
{
int i,k,m;
for(i=1;i<=n;i++)
x[i]=0;
k=1;
while(k>=1)
{
x[k]=x[k]+1;
while(x[k]<=n&&!place(k))
x[k]=x[k]+1;
if(x[k]<=n&&k==n)
{
for(i=1;i<=n;i++)
m=m+1;
}
else if(x[k]<=n&&k<n)
k=k+1;
else
{
x[k]=0;
k=k-1;
}
}
if(n==1)
printf("1\n");
else printf("%d\n",m/8);
}
int main()
{
int n;
scanf("%d",&n);
queue(n);
} 这个程序在自己电脑上运行很好,但是交作业就不行,回编译失败,问题是函数没有声明,请问各位大神如何声明?
main.c:12: error: `false' undeclared (first use in this function)
main.c:12: error: (Each undeclared identifier is reported only once
main.c:12: error: for each function it appears in.)
main.c:13: error: `true' undeclared (first use in this function
这是我提交后系统给我的错误提示