#include
#include
#include
#include
#define MAX 8
int board[MAX];
void Drow()
{
int i;
int Driver=VGA,Mode=VGAHI;
initgraph(&Driver,&Mode,”d:\\TC3.0\\bgi”);
setfillstyle(SOLID_FILL, BLUE);
bar(5,15,600,500);
setcolor(YELLOW);
for(i=0;i<=9;i++)
{
line(10,20+50*i,460,20+50*i);
}
for(i=0;i<=9;i++)
{
line(10+50*i,20,10+50*i,470);
}
line(460,20,560,20);
line(10,470,560,470);
line(560,470,560,20);
setcolor(RED);
outtextxy(465,30,”WuShan gjie”);
outtextxy(465,45,”Eight Queue”);
outtextxy(465,60,”CopyRi ght1.0″);
outtextxy(415,440,”Start “);
outtextxy(385,440, “0″);
outtextxy(335,440, “1″);
outtextxy(285,440, “2″);
outtextxy(235,440, “3″);
outtextxy(185,440, “4″);
outtextxy(135,440, “5″);
outtextxy(85,440,” 6″);
outtextxy(35,440,” 7″);
outtextxy(415,455,”Point”);
outtextxy(435,390, “0″);
outtextxy(435,340, “1″);
outtextxy(435,290, “2″);
outtextxy(435,240, “3″);
outtextxy(435,190, “4″);
outtextxy(435,140, “5″);
outtextxy(435,90,” 6″);
outtextxy(435,40,” 7″);
}
void DrowCircle(int i,int j)
{
char text[80];
setfillstyle(SOLID_FILL,YELLOW);
setcolor(YELLOW);
circle(385-50*i,395-50*j,15);
floodfill(385-50*i,395-50*j,YELLOW);
setcolor(RED);
sprintf(text,”%d,%d”,i,j);
outtextxy(385-50*i-14,395-50*j,text);
}
void GiveDrowIn(int i,int j)
{
setfillstyle(SOLID_FILL,BLUE);
setcolor(BLUE);
circle(385-50*i,395-50*j,15);
floodfill(385-50*i,395-50*j,BLUE);
outtextxy(385-50*i-14,395-50*j,” ”);
}
void show_result()
{
int j;
for(j=0;j {
// printf(“(%d,%d)”,j,boa rd[j]);
DrowCircle(j,board[j]);
}
getch();
for(j=0;j {
GiveDrowIn(j,board[j]);
}
getch();
}
int check_cross(int n)
{
int k;
for(k=0;k if(board[k]==board[n]||(n-k)==abs(board[k]-board[n]))
return 1;
}
return 0;
}
void put_chess(int n)
{
for(int l=0;l board[n]=l;
if(!check_cross(n)){
if(n==MAX-1) {
show_result();
}
else put_chess(n+1);
}
}
}
void main()
{
Drow();
put_chess(0);
return;
// clrscr();
}
-
近期文章
近期评论
- coolker 发表在《打造最快的Hash表》
- struggle 发表在《提供C语言教学课件(适用于初学者)》
- zhanghaibo 发表在《提供C语言教学课件(适用于初学者)》
- zhanghaibo 发表在《提供C语言教学课件(适用于初学者)》
- diys 发表在《C语言编程宝典(王大刚) 1.1 C 语言的产生与发展》
文章归档
- 2022 年十月
- 2014 年一月
- 2013 年十二月
- 2012 年十一月
- 2012 年七月
- 2012 年六月
- 2012 年五月
- 2012 年四月
- 2012 年三月
- 2012 年二月
- 2011 年十二月
- 2011 年十月
- 2011 年九月
- 2011 年八月
- 2011 年七月
- 2011 年六月
- 2011 年五月
- 2011 年四月
- 2011 年三月
- 2011 年二月
- 2011 年一月
- 2010 年十二月
- 2010 年十一月
- 2010 年十月
- 2010 年九月
- 2010 年八月
- 2010 年七月
- 2010 年六月
- 2010 年五月
- 2010 年四月
- 2010 年三月
- 2010 年二月
- 2010 年一月
- 2009 年十二月
- 2009 年十一月
- 2009 年十月
- 2009 年九月
- 2009 年八月
- 2009 年七月
- 2009 年六月
- 2009 年五月
- 2009 年四月
- 2009 年三月
- 2009 年二月
- 2009 年一月
- 2008 年十二月
- 2008 年十一月
- 2008 年十月
- 2008 年九月
- 2008 年八月
- 2008 年七月
- 2008 年六月
- 2008 年五月
- 2008 年四月
- 2008 年三月
- 2008 年二月
- 2008 年一月
- 2007 年十二月
- 2007 年十一月
- 2007 年十月
- 2007 年九月
- 2007 年八月
- 2007 年七月
- 2007 年六月
- 2007 年三月
- 2007 年二月
- 2007 年一月
- 2006 年十二月
- 2006 年十一月
- 2006 年十月
- 2006 年九月
- 2006 年八月
- 2006 年七月
- 2006 年六月
- 2006 年五月
- 2006 年四月
- 2006 年三月
- 2006 年二月
- 2006 年一月
- 2005 年十二月
- 2005 年十一月
分类目录
功能