#include <iostream.h> struct point { int x,y;//马的位置 int dir;//这一次马行走的方向 }; struct stack { point p[64];//存储马的位置,方便回溯 }; int board [8][8]; int Htry1[8]={-2,-1,1,2,2,1,-1,-2}; int Htry2[8]={1,2,2,1,-1,-2,-2,-1}; bool chech[8][8]={0};//标记位置是否已经被占用 int main() { int i,j; int top=0; int z; cout<<"请输入马的初始位置"; cin>>i; cin>>j; stack sta; sta.p[top].x=i; sta.p[top].y=j; board [i][j]=top; chech [i][j]=true; int nx; int ny; for(int u=0;u<64;u++) sta.p[u].dir=0;//把每个结点的dir清零 for(z=0;;) { if(sta.p[top].x+Htry1[z]>=0&&sta.p[top].x+Htry1[z]<8&& sta.p[top].y+Htry2[z]>=0&&sta.p[top].y+Htry2[z]<8&& !chech [sta.p[top].x+Htry1[z]][sta.p[top].y+Htry2[z]]//检查要走的下个位置是否可行 ) { nx=sta.p[top].x+Htry1[z]; ny=sta.p[top].y+Htry