#include <stdio.h> #include <conio.h> int x[9]={0}; int n=1; int chk(int a, int b) /*检测(x,y)处的皇后是否与已有皇后冲突,同行、同斜线均为冲突。*/ { int i; if(a != 0) { for(i=1; i <= a; i++) { if((b == x[i]) ¦ ¦ (a - i == b - x[i]) ¦ ¦ (a - i == x[i] - b)) { return 0; /*代表有冲突*/ } } }
return 1; /*没有冲突*/ }
void output() { int i,j; for(i=1;i <=8;i++) for(j=1;j <=8;j++) {gotoxy(j+1,i); printf(".");} for(i=1;i <=8;i++) {gotoxy(i+1,x[i]); printf("o");} gotoxy(20,10); printf("view the %d font now!\n",n++); getch(); }