《数据结构》课程设计报告——马踏棋盘(7)

2020-12-24 19:32

if(a-2>=0&&b-1>=0&&board[a-2][b-1]==0) count++;

if(a-2>=0&&b+1<M&&board[a-2][b+1]==0) count++;

if(a+2<M&&b-1>=0&&board[a+2][b-1]==0) count++;

if(a+2<M&&b+1<M&&board[a+2][b+1]==0) count++;

if(a-1>=0&&b+2<M&&board[a-1][b+2]==0) count++;

if(a-1>=0&&b-2>=0&&board[a-1][b-2]==0) count++;

if(a+1<M&&b+2<M&&board[a+1][b+2]==0) count++;

if(a+1<M&&b-2>=0&&board[a+1][b-2]==0) count++; return count ; }

//寻找路径函数

void findway(int m,int n) {

dir f[8],path ; int i,j,k, stepnum ; stepnum=1 ; i=m ; j=n ;

printf("output the position and the number of the position:\n"); while(stepnum<M*M && i>=0 && j>=0) {

board[i][j]=stepnum; printf("%d,%d,%d ",i,j,board[i][j]);

path.pathnum=8 ; //用来标志可走方向数的最小值 for(k=0;k<8;k++) //对方向数组赋初值 {

f[k].r=-1 ; f[k].c=-1 ; }

//如果第一个方向可走,则将坐标及可选方向数赋给f[0],以下同理 if(i-2>=0&&j-1>=0) {

f[0].r=i-2 ; f[0].c=j-1 ;

f[0].pathnum=pathnum(f[0].r,f[0].c); }


《数据结构》课程设计报告——马踏棋盘(7).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:空气过滤器的等级划分

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: