//在半张中国象棋棋盘上,一只马从左下角跳到右上角,只允许往右跳,//不允许往左跳,问有多少种跳步方案。#include <iostream>#define startx 0#define starty 0#define endx 8#define endy 4using namespace std;int num=0;bool Roads(int xpos,int ypos){ int directx,directy; bool found=false; if(xpos==endx&&ypos==endy) return true; for(directx=1;directx<=2;directx++) for(directy=-2;directy<=2;directy++) { if(directy==0) continue; if(directx==1&&directy%2!=0) continue; if(directx==2&&directy%2==0) continue; if(directx>8||directy>4||directy<0) continue; if(Roads(xpos+directx,ypos+directy)) { num++; break; } } return found;}int main(){ if(Roads(startx,starty,num)) cout<<"there is "<<num<<" road to reach the target"<<endl; system("pause"); return 0;}