圈叉棋
#include
#include
#include
#define up 0x4800
#define down 0x5000
#define left 0x4b00
#define right 0x4d00
#define esc 0x011b
#define space 0x3920
int ding[19][19];
void outbiao(int x,int y) {
setcolor(WHITE);
line(x-45,y-10,x-45,y-45);
line(x-45,y-45,x-10,y-45);
line(x+45,y-10,x+45,y-45);
line(x+45,y-45,x+10,y-45);
line(x-45,y+10,x-45,y+45);
line(x-45,y+45,x-10,y+45);
line(x+45,y+10,x+45,y+45);
line(x+45,y+45,x+10,y+45); }
void clsbiao(int x,int y) {
setcolor(BLACK);
line(x-45,y-10,x-45,y-45);
line(x-45,y-45,x-10,y-45);
line(x+45,y-10,x+45,y-45);
line(x+45,y-45,x+10,y-45);
line(x-45,y+10,x-45,y+45);
line(x-45,y+45,x-10,y+45);
line(x+45,y+10,x+45,y+45);
line(x+45,y+45,x+10,y+45); }
int dingxy(int x,int y)
{
if (ding[(x-50)/100-1][(y-50)/100-1]==0) return 1; else return 0;
}
int yeah(int x,int y,int vs) {
int n1=1,n2=1,n3=1,n4=1,i,l=1,r=1,t=1,d=1,lt=1,rd=1,rt=1,ld=1;
for(i=1;i<=2;i++){
if (l==1 && ding[x-i][y]==vs) n1++;else l=0;
if (r==1 && ding[x+i][y]==vs) n1++;else r=0;
if (t==1 && ding[x][y-i]==vs) n2++;else t=0;
if (d==1 && ding[x][y+i]==vs) n2++;else d=0;
if (lt==1 && ding[x-i][y-i]==vs) n3++;else lt=0;
if (rd==1 && ding[x+i][y+i]==vs) n3++;else rd=0;
if (rt==1 && ding[x+i][y-i]==vs) n4++;else rt=0;
if (ld==1 && ding[x-i][y+i]==vs) n4++;else ld=0;
}
if (n1>=3||n2>=3||n3>=3||n4>=3) return 1;else return 0; }
void cursor(int x,int y) /* ?,Ê?×Ö?â?êº?Êý */ {
int x1,x2,y1,y2;
x1=x-25;
x2=x+25;
y1=y-25;
y2=y+25;
setcolor(15);
line(x1,y1,x2,y2);
line(x1,y2,x2,y1);
}
main()
{
int drive,mode,x,y,i,j,key,x1,x2,y1,y2,player;
player=1;
drive=DETECT;
initgraph(&drive,&mode,"c:\\tc");
setbkcolor(0);
cleardevice( );
setcolor(14);
setlinestyle(4,0x1001,3);
rectangle(100,100,400,400);
line(100,200,400,200);
line(100,300,400,300);
line(200,100,200,400);
line(300,100,300,400);
circle(570,480,95);
setcolor(12);
setlinestyle(2,0,3);
circle(650,380,60);
circle(100,100,30);
setcolor(11);
moveto(440,50);
outtext("Player key:");
moveto(440,300);
outtext(" PUT INTO : "); setlinestyle(2,0,3); circle(440,335,12); setlinestyle(2,0,3); circle(570,480,110); setlinestyle(2,0,3); circle(100,100,20); setcolor(2);
setlinestyle(2,0,3); circle(50,230,13); setcolor(5);
setlinestyle(2,0,3); circle(600,0,60); circle(59,240,8); setcolor(6);
setlinestyle(2,0,3); circle(450,350,20); circle(85,425,40); setcolor(10);
setlinestyle(2,0,3); circle(85,425,25); setcolor(7);
setlinestyle(2,0,3); circle(120,445,18); setcolor(4);
setlinestyle(2,0,3); circle(450,372,6); settextstyle(1,0,4); moveto(475,100);
outtext(" UP -- up"); moveto(475,150);
outtext(" DOWN -- down"); moveto(475,200);
outtext(" LEFT -- left"); moveto(475,250);
outtext("RIGHT -- right");
moveto(475,330);
outtext(" space");
setlinestyle(0,0,1);
x=50;y=50;
outbiao(x,y);
while(1){
key=bioskey(0);
if (key==up){
if (y>200){
clsbiao(x,y);
y-=100;
outbiao(x,y);
}
}
if (key==down){
if(y<300){
clsbiao(x,y);
y+=100;
outbiao(x,y);
}
}
if (key==left){
if (x>200){
clsbiao(x,y);
x-=100;
outbiao(x,y);
}
}
if (key==right){
if (x<300){
clsbiao(x,y);
x+=100;
outbiao(x,y);
}
}
if (key==space){
if (dingxy(x,y)!=0){
i=(x-50)/100-1;
j=(y-50)/100-1;
if (player==1)
{
setcolor(15);
setlinestyle(0,0,3);
circle(x,y,35);
setlinestyle(0,0,1);
ding[i][j]=1;
if (yeah(i,j,1)==1)
{
moveto(200,200);
settextstyle(0,0,4);
setcolor(9);
outtext("O WIN !!!");
break;
}
player=2;
}
else
{
setlinestyle(0,0,3);
cursor(x,y);
setlinestyle(0,0,1);
ding[i][j]=2;
if (yeah(i,j,2)==1)
{
moveto(200,200);
settextstyle(0,0,4);
setcolor(9);
outtext("X WIN !!!");
break;
}
player=1;
}
}
}
if (key==esc) break;
}
moveto(130,300);
settextstyle(0,0,2);
setcolor(4);
outtext("Press any key to Quit...");
getch();
closegraph();
}
???????????????????????152????????????????????????????????????????
????????????
??????????????????????????????????????????????????????????????????
???????????????????????????????????????????????? ??????????????????????????????????????????????????????????????????
???????????????
??????????????????????????????????????????????????????????????????
????????????????????????
??????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ??????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????
??????1000???
???????????????????????????
??????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????? ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????——?????????????????????
???????
????????????????????????????????????????????????????????? ??????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????
??????1000???
??????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????
??????1000???
??????????????????????????????.??????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????——??????????????????
????????.??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????.???????????????????????????????????????????
?.????????????????????????????????????????????????????????......??????????????,??????????,????.??????????????,????????????.
??????????????????????????????????????????????????????,??????????.????????????????,???????????????????????????????????????????????????????????,????,?????.????????????.?????????????,????????????????“???????????????????????????????????????????”?“??????????”?????????????????????????????????????????????????????????????????????,??????????????????,????????????????,???????????????.????????????????????????????????????????????????????????????????
?????????????——????????????????????????????????????????????????????????????——??????????????????????????
????????????????????????????????????????????????????????????????????????????????????????“???????????????????????”????????????????——?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????1000???
??????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????"???????????"????????????????????????????????????????????????????????????????????????:"???????????""?????????--?????????!""???????????????????????????--?????????????????????????????????????????????--???????????!"
????????????????????????????????????????????--???????????????????????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????-?????????????????????=??+??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????1000???
???????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????
??????????????????????????????????????????“??????????????????????????????????”??????????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????——????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????“???????????????????????——????????????????????????????”??????????????????????
????????????????????????????????????18????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????“????????????????????????????……???????????????????????????????????????????????——?????????”??????????????????????????????????????????????????????
????????????????????????????????????????????
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????
????????????????????????????????19??????????????????????
?????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????
?????????????????????
?????????????????????????????????????——???????????????????????
?? ——??
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????????????????????????????????????????????????????????????????????????????????——?????????????????????????????????????????????????????????????reader8.cn???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????
???????????????????????????????????????????????????????????????????3COME?????????????????????????????????????????????
??????????????????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????????——?????????