e35 马走日棋盘问题
```#include<stdio.h>
int qipan;
int x1,y1;
int x2,y2;
int check1 ;
int k,n,m;
int check2 ;
int count1 =1;
int count = 1;
int check(int,int);
int main ()
{
int c,z=0,x,y,l;
check1 = -1;
check1 = -1;
for(c=0;c<8;c++)
{
for(z=0;z<8;z++)
{
qipan = 0;
}
}
printf("请选择你的起始位置:");
scanf("%d %d",&x,&y);
l = qipan = count1++;
check(x,y);
for(c=0;c<8;c++)
{
for(z=0;z<8;z++)
{
printf("%2d",qipan);
}
printf("\n");
}
return 0;
}
int check(int x,int y)
{
int i=0,j=0;
int p1 = {{x-2,y-1},{x-2,y+1},{x-1,y+2},{x-1,y-2},{x+1,y-2},{x+1,y+2},{x+2,y-1},{x+2,y+1}};
int (*p2) =p1;
for(i=0;i<8;i++)
{
for(j=0;j<2;j++)
{
if(*(*(p2+i)+j)>=0&&*(*(p2+i)+j)<8)
{
k = check1 = *(*(p2+i)+j);
}
}
if(check1 == -1 ||check1 == -1)
{
check1 = check1 = -1;
}
if(check1!=-1&&check1 !=-1)
{
if(qipan]]==0)
{
qipan]] = count1++;
x2 = check1;
y2 = check1;
check1 = check1 = -1;
count++;
if(count<64)
{
x1 = x;
y1 = y;
check(x2,y2);
}
else
{
return 1;
}
}
check1 = check1 = -1;
}
}
qipan = 0;
x = x1;
y = y1;
return 0;
}
``` 什么问题 万千只cnm 发表于 2021-7-14 19:08
什么问题
#include<stdio.h>
int qipan;
int x1,y1;
int x2,y2;
int check1 ;
int k,n,m;
int check2 ;
int count1 =1;
int count = 1;
int check(int,int);
int main ()
{
int c,z=0,x,y,l;
check1 = -1;
check1 = -1;
for(c=0;c<8;c++)
{
for(z=0;z<8;z++)
{
qipan = 0;
}
}
printf("请选择你的起始位置:");
scanf("%d %d",&x,&y);
l = qipan = count1++;
check(x,y);
for(c=0;c<8;c++)
{
for(z=0;z<8;z++)
{
printf("%2d",qipan);
}
printf("\n");
}
return 0;
}
int check(int x,int y)
{
int i=0,j=0;
int p1 = {{x-2,y-1},{x-2,y+1},{x-1,y+2},{x-1,y-2},{x+1,y-2},{x+1,y+2},{x+2,y-1},{x+2,y+1}};
int (*p2) =p1;
for(i=0;i<8;i++)
{
for(j=0;j<2;j++)
{
if(*(*(p2+i)+j)>=0&&*(*(p2+i)+j)<8)
{
k = check1 = *(*(p2+i)+j);
}
}
if(check1 == -1 ||check1 == -1)
{
check1 = check1 = -1;
}
if(check1!=-1&&check1 !=-1)
{
if(qipan]]==0)
{
qipan]] = count1++;
x2 = check1;
y2 = check1;
check1 = check1 = -1;
count++;
if(count<64)
{
x1 = x;
y1 = y;
check(x2,y2);
}
else
{
return 1;
}
}
check1 = check1 = -1;
}
}
x = x1;
y = y1;
return 0;
}
我已经做出来了并附上我的正确代码有些代码变量是调试需要的没啥特别意义感谢各位 #include<stdio.h>
int qipan;
int x1,y1;
int x2,y2;
int check1 ;
int k,n,m;
int check2 ;
int count1 =1;
int count = 1;
int check(int,int);
int main ()
{
int c,z=0,x,y,l;
check1 = -1;
check1 = -1;
for(c=0;c<8;c++)
{
for(z=0;z<8;z++)
{
qipan = 0;
}
}
printf("请选择你的起始位置:");
scanf("%d %d",&x,&y);
l = qipan = count1++;
check(x,y);
for(c=0;c<8;c++)
{
for(z=0;z<8;z++)
{
printf("%2d",qipan);
}
printf("\n");
}
return 0;
}
int check(int x,int y)
{
int i=0,j=0;
int p1 = {{x-2,y-1},{x-2,y+1},{x-1,y+2},{x-1,y-2},{x+1,y-2},{x+1,y+2},{x+2,y-1},{x+2,y+1}};
int (*p2) =p1;
for(i=0;i<8;i++)
{
for(j=0;j<2;j++)
{
if(*(*(p2+i)+j)>=0&&*(*(p2+i)+j)<8)
{
k = check1 = *(*(p2+i)+j);
}
}
if(check1 == -1 ||check1 == -1)
{
check1 = check1 = -1;
}
if(check1!=-1&&check1 !=-1)
{
if(qipan]]==0)
{
qipan]] = count1++;
x2 = check1;
y2 = check1;
check1 = check1 = -1;
count++;
if(count<64)
{
x1 = x;
y1 = y;
check(x2,y2);
}
else
{
return 1;
}
}
check1 = check1 = -1;
}
}
x = x1;
y = y1;
return 0;
}
页:
[1]