这只是五子棋的一个排列判定,只能输入坐标两人对仗. 缺少图象函数和鼠标函数;
请指点怎样才能让它选择重玩和鼠标函数的的写法 ,
请多多指教!!!
#include"stdio.h"
#include"math.h"
#define NUM1 5 /*改变棋盘的宽 要大于4*/
#define NUM2 5 /*改变棋盘的长 要大于4*/
#define W 27 /*比NUM1*NUM2+1大的数*/
#define V 28 /*比NUM1*NUM2+2大的数 W不能等于V */
main()
{ static int a[NUM1][NUM2],b[NUM1][NUM2],c[NUM1+1][NUM2+1];
/*c数组比a,b大 第一横和列作为坐标 方便输入*/
int x,y,i,j,m,n,f=1;
int p=0;
int zuo_biaox=0,zuo_biaoy=0;
for(zuo_biaox=1;zuo_biaox<NUM1+1;zuo_biaox=zuo_biaox+1)
c[0][zuo_biaox]=zuo_biaox-1;
for(zuo_biaoy=1;zuo_biaoy<NUM2+1;zuo_biaoy=zuo_biaoy+1)
c[zuo_biaoy][0]=zuo_biaoy-1;
for(p=0;p<=NUM1*NUM2;p=p+1)
{int e=1;
int m1=1,n1=1,t1=0,s1=0,flag1=0,flak1=0,z1=0;
int m2=1,n2=1,t2=0,s2=0,flag2=0,flak2=0,z2=0;
int m3=1,n3=1,t3=0,s3=0,flag3=0,flak3=0,z3=0;
int m4=1,n4=1,t4=0,s4=0,flag4=0,flak4=0,z4=0;
f=-f;
if(f<0)
printf("A: inputx&y:\n");
if(f>0)
printf("B: inputx&y:\n");
scanf("%d %d", &x,&y );
if((x>=NUM2)(y>=NUM1)) /*坐标不能超过棋盘格数*/
{f=-f;printf("the number is too big !\n");continue;}
if(c[y+1][x+1]!=0) /*已下棋的坐标不能再输入*/
{f=-f;printf("you can not put here!\n");continue;}
i=x;
j=y;
if(f<0){c[j+1][i+1]=1,c[0][0]=1;}
if(f>0){c[j+1][i+1]=2,c[0][0]=2;}
if(f<0) /*判定a 数组*/
{a[j][i]=1;
for(e=1 ;e<=4;e=e+1)
{switch(e)
{case 1: /*判定前后数值是否与自己相同*/
while ((m1<=5)&&(flag1==0))
{if(a[j][i+m1]/1==1)
{m1=m1+1, t1=t1+1,printf("t1=%d \n",t1);}
else flag1=1;
}
while ((n1<=5)&&(flak1==0))
{if(a[j][i-n1]/1==1)
{n1=n1+1,s1=s1+1,printf(" s1=%d \n",s1);}
else flak1=1;
}
z1=s1+t1+1;
if(z1>=5) {p=W ;e=10;}
break;
case 2: /*判定上下数值是否与自己相同*/
while ((m1<=5)&&(flag2==0))
{if(a[j+m2][i]/1==1)
{m2=m2+1, t2=t2+1,printf("t2=%d \n",t2);}
else flag2=1;
}
while ((n2<=5)&&(flak2==0))
{if(a[j-n2][i]/1==1)
{n2=n2+1,s2=s2+1,printf(" s2=%d \n",s2);}
else flak2=1;
}
z2=s2+t2+1;
if(z2>=5) {p=W ;e=10;}
break;
case 3: /*判定右倾斜数值是否与自己相同*/
while ((m3<=5)&&(flag3==0))
{if(a[j-m3][i+m3]/1==1)
{m3=m3+1, t3=t3+1,printf("t3=%d \n",t3);}
else flag3=1;
}
&nbs