#include<stdio.h>
#include<math.h>
const int NUM=8;
char model[]="12345678";
char solve[]="???????? ";
int main()
{
void queen(int);
printf("the 92 solutions of Eight Queen's problem: \n");
queen(0);
printf("\n");
return 0;
}
void queen(int n)
{ static tot=0;
int i=NUM;
char ch,*p,*q;
if(n<i)
for(p=model;i>0;i--,p++)
{
int j;
q=solve;
ch=*p;
if(ch==0)continue;
for(j=n;j>0;j--)
if(abs(*q++-ch)==j)break;
if(j>0)continue;
*q=ch;
*p=j;
queen(n+1);
*p=ch;
}
else
{
printf(solve);
}
}