数据结构习题10答案.docxVIP

  • 5
  • 0
  • 约1.91万字
  • 约 41页
  • 2021-11-22 发布于四川
  • 举报
习题十 1. #include iostream #include stdio.h #include stdlib.h #define max 101 int count = 0; int m, n;//棋盘大小 int start_x, start_y;//起点位置 //考虑到马有8种走法 int dx[8] = { -2,-1,1,2,-2,-1,2,1 }; int dy[8] = { -1,-2,-2,-1,1,2,1,2 }; int board[max][max] = { 0 }; //输出棋盘 void show(int m, int n) { for (int i = 0; i m; i++) { for (int j = 0; j n; j++) { std::cout board[i][j] ; } std::cout std::endl; } } //判断下一步是否是起始的位置 int next_move(int x, int y) { for (int i = 0; i 8; i++) { if (board[x + dx[i]][y + dy[i]] == 1) {//1表示马的起始位置 return 1; } } return 0; } //判断是否填了 int finish(int x,

文档评论(0)

1亿VIP精品文档

相关文档