#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef struct
{
int x,y;
}Location;
int t=0;
int check(int i,Location c[])
{
int j;
for(j=0;j<c[i].x;j++)
{
if( (c[i].x==c[j].x) ||c[i].y==c[j].y || (c[j].y-c[i].y)==(c[j].x-c[i].x) || (c[j].y-c[i].y==(c[i].x-c[j].x)) )
return 0;
}
return 1;
}
void find(int i,int n,Location c[])
{
int j;
if(i==n)
{
for(j=0;j<n;j++)
printf("(%d,%d) ",c[j].x,c[j].y);
t++;
printf("\n");
}
else
{
for(j=0;j<n;j++)
{
c[i].x=i;
c[i].y=j;
if(check(i,c))
find(i+1,n,c);
}
}
}
int main()
{
Location c[8];
find(0,8,c);
printf("sum=%d\n",t);
system("pause");
return 0;
}
08-11