#include<stdio.h>
#include<math.h>
#define NUM1 5
#define NUM2 5
#define W 27
#define V 28
main()
{ static int a[NUM1][NUM2],b[NUM1][NUM2],c[NUM1+1][NUM2+1];
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[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;
}
while ((n3<=5)&&(flak3==0))
{if(a[j+n3][i-n3]/1==1)
{n3=n3+1,s3=s3+1,printf(" s3=%d \n",s3);}
else flak3=1;
}
z3=s3+t3+1;
if(z3>=5) {p=W; e=10;}
break;
case 4:
while ((m4<=5)&&(flag4==0))
{if(a[j-m4][i-m4]/1==1)
{m4=m4+1, t4=t4+1,printf("t4=%d \n",t4);}
else flag4=1;
}
while ((n4<=5)&&(flak4==0))
{if(a[j+n4][i+n4]/1==1)
{n4=n4+1,s4=s4+1,printf(" s4=%d \n",s4);}
else flak4=1;
}
z4=s4+t4+1;
if(z4>=5) {p=W; e=10;}
break;
}
}
}
if(f>0)
{b[j][i]=2;
for(e=1 ;e<=4;e=e+1)
{switch(e)
{case 1:
while ((m1<=5)&&(flag1==0))
{if(b[j][i+m1]/2==1)
{m1=m1+1, t1=t1+1,printf("t1=%d \n",t1);}
else flag1=1;
}
while ((n1<=5)&&(flak1==0))
{if(b[j][i-n1]/2==1)
{n1=n1+1,s1=s1+1,printf(" s1=%d \n",s1);}
else flak1=1;
}
z1=s1+t1+1;
if(z1>=5) {p=V; e=10;}
break;
case 2:
while ((m1<=5)&&(flag2==0))
{if(b[j+m2][i]/2==1)
{m2=m2+1, t2=t2+1,printf("t2=%d \n",t2);}
else flag2=1;
}
while ((n2<=5)&&(flak2==0))
{if(b[j-n2][i]/2==1)
{n2=n2+1,s2=s2+1,printf(" s2=%d \n",s2);}
else flak2=1;
}
z2=s2+t2+1;
if(z2>=5) {p=V; e=10;}
break;
case 3:
while ((m3<=5)&&(flag3==0))
{if(b[j-m3][i+m3]/2==1)
{m3=m3+1, t3=t3+1,printf("t3=%d \n",t3);}
else flag3=1;
}
while ((n3<=5)&&(flak3==0))
{if(b[j+n3][i-n3]/2==1)
{n3=n3+1,s3=s3+1,printf(" s3=%d \n",s3);}
else flak3=1;
}
z3=s3+t3+1;
if(z3>=5) {p=V; e=10;}
break;
case 4:
while ((m4<=5)&&(flag4==0))
{if(b[j-m4][i-m4]/2==1)
{m4=m4+1, t4=t4+1,printf("t4=%d \n",t4);}
else flag4=1;
}
while ((n4<=5)&&(flak4==0))
{if(b[j+n4][i+n4]/2==1)
{n4=n4+1,s4=s4+1,printf(" s4=%d \n",s4);}
else flak4=1;
}
z4=s4+t4+1;
if(z4>=5) {p=V; e=10;}
break;
}
}
}
for(m=0;m<NUM1+1;m=m+1)
{printf("\n");
for(n=0;n<NUM2+1;n=n+1)printf("%d ",c[m][n]);}
printf("\n");
if(p>=NUM1*NUM2+1) break;
}
for(m=0;m<NUM1+1;m=m+1)
{printf("\n");
for(n=0;n<NUM2+1;n=n+1)printf("%d ",c[m][n]);
printf("\n");}
printf("p=%d\n",p);
if(p==W) printf("The winner is A!\n");
if(p==V) printf("The winner is B!\n");
if(p==NUM1*NUM2+1) printf("Noone win!");
}
我觉得这里
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;
的0要改成
for(zuo_biaox=1;zuo_biaox<NUM1+1;zuo_biaox=zuo_biaox+1)
for(zuo_biaoy=1;zuo_biaoy<NUM2+1;zuo_biaoy=zuo_biaoy+1)
c[zuo_biaoy][zuo_biaox]=zuo_biaoy-1;
也不知道对不对,希望大家能给点意见,我好改改,谢谢了.