j=j-1 ; }
else if(i+1<M&&j-2>=0&&board[i+1][j-2]==0) {
i=i+1 ; j=j-2 ; }
else if(i-1>=0&&j-2>=0&&board[i-1][j-2]==0) {
i=i-1 ; j=j-2 ; }
board[i][j]=M*M ;
printf("%d,%d,%d",i,j,board[i][j]); }
void main() {
int r,c,i,j ;
printf("input the start position,such as 3,4 the row and col must be between 0 and 7 :");
scanf("%d,%d",&r,&c); while(r<0||r>7||c<0||c>7){
printf("the position is invaliable ,please input again:"); scanf("%d,%d",&r,&c); }
findway(r,c); printf("\n");
//输出棋盘上的路径
printf("output the path of the chess set....:\n"); for(i=0;i<M;i++) { for(j=0;j<M;j++) printf("%4d",board[i][j]); printf("\n"); } getch(); }
四、调试分析
调试情况及设计技巧和相关方法:
1.该开始想着利用栈的数据结构,记录回溯的相关信息,后来查资料发现如
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库《数据结构》课程设计报告——马踏棋盘(10)在线全文阅读。
相关推荐: