马从左上角开始走,数字代表第几步,90步刚好走完全场
源码如下(运行时间比较长)
//功能:在棋盘上用马不重复的走完每一格(可能会花好一段时间)
//时间 2015-4-23
#include <stdio.h>
#include <time.h>
#define X 10
#define Y 9
int chess[X][Y]={0};
int nextxy(int *x, int *y, int count)
{
switch(count)
{
case 0: if( *x+2<X && *y-1>=0 && chess[*x+2][*y-1]==0)
{
*x+=2; *y-=1; return 1;
} break;
case 1: if( *x+2<X && *y+1<Y && chess[*x+2][*y+1]==0)
{
*x+=2; *y+=1; return 1;
} break; //往下边移动
case 2: if( *x-2>=0 &am