鱼C论坛

 找回密码
 立即注册
查看: 1695|回复: 14

[已解决]分享一个五子棋的程序,以及一个bug大佬看看怎么回事

[复制链接]
发表于 2019-1-28 14:45:48 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
本帖最后由 cookies945 于 2019-1-28 14:46 编辑
  1. #include <stdio.h>
  2. #define MAX 13
  3. #define MIN 1

  4. int addBlack(int row_in_fun,int col_in_fun,int count);
  5. int addWhite(int row_in_fun,int col_in_fun,int count);
  6. void cleanChessBoard(char* CB,int n);
  7. int judge(int row_in_fun,int col_in_fun,int trun);
  8. void printChessBoard(void);
  9. void choose(void);
  10. int judge_N(int row,int col,int turn);
  11. int judge_S(int row,int col,int turn);
  12. int judge_E(int row,int col,int turn);
  13. int judge_W(int row,int col,int turn);
  14. int judge_NW(int row,int col,int turn);
  15. int judge_NE(int row,int col,int turn);
  16. int judge_SE(int row,int col,int turn);
  17. int judge_SW(int row,int col,int turn);

  18. char chessBoard[14][14];
  19. char chess[2] = {'0','@'};
  20. int main(){       
  21.         char *CB;
  22.         CB = &chessBoard[0][0];
  23.         cleanChessBoard(CB,14);
  24.         choose();
  25.         return 0;
  26. }
  27. void cleanChessBoard(char* CB,int n){
  28.         int i,j;
  29.         for(i = 0;i < n;i++){  // n 为行
  30.                 for(j = 0;j < n;j++){ // j 为列
  31.        
  32.                         if(i == 0){
  33.                                 printf("%2d",j); // 第一行打印棋盘上面的数字坐标
  34.                                
  35.                         }
  36.                         else if(j == 0 && i != 0){ //每一行的开头打印列标
  37.                                 printf("%2d",i);
  38.                         }
  39.                         else{
  40.                                 printf(" ");
  41.                                 *(CB + i*n + j) = '*';       //未落子的区域打印 * 表明未落子;
  42.                                 printf("%c",chessBoard[i][j]);   
  43.                         } // 打印棋盘
  44.                         printf("  ");
  45.                 }
  46.                 printf("\n");
  47.         }
  48. }
  49. int addBlack(int row_in_fun,int col_in_fun,int count){
  50.         int flag;//接收judge的返回值,判断是否结束比赛
  51.         if(chessBoard[row_in_fun][col_in_fun] == '*'){   //判断该区域是否已经落了子
  52.                 chessBoard[row_in_fun][col_in_fun] = '@';
  53.                 flag = judge(row_in_fun,col_in_fun,count);
  54.                 if(flag){
  55.                         printf("黑棋获胜!\n");
  56.                         return 1;
  57.                 }
  58.         }
  59.         else{
  60.                 printf("这里有棋子了!");
  61.                 printf("重新输入坐标:");
  62.                 int row,col;
  63.                 scanf("%d %d",&row,&col);
  64.                 addBlack(row,col,count);
  65.         }
  66.         return 0;
  67. }
  68. int addWhite(int row_in_fun,int col_in_fun,int count){
  69.         int flag;//接收judge的返回值,判断是否结束比赛
  70.         if(chessBoard[row_in_fun][col_in_fun] == '*'){
  71.                 chessBoard[row_in_fun][col_in_fun] = '0';
  72.                 flag = judge(row_in_fun,col_in_fun,count);
  73.                 if(flag){
  74.                         printf("白棋获胜!\n");
  75.                         return 1;
  76.                 }
  77.         }
  78.         else{
  79.                 printf("这里有棋子了!");
  80.                 printf("重新输入坐标:");
  81.                 int row,col;
  82.                 scanf("%d %d",&row,&col);
  83.                 addWhite(row,col,count);
  84.         }
  85.         return 0;
  86. }
  87. void printChessBoard(void){
  88.         int i,j;
  89.         for(i = 0;i < 14;i++){  // n 为行
  90.                 for(j = 0;j < 14;j++){ // j 为列
  91.        
  92.                         if(i == 0){
  93.                                 printf("%2d",j); // 第一行打印棋盘上面的数字坐标
  94.                                
  95.                         }
  96.                         else if(j == 0 && i != 0){ //每一行的开头打印列标
  97.                                 printf("%2d",i);
  98.                         }
  99.                         else{
  100.                                 printf(" ");             
  101.                                 printf("%c",chessBoard[i][j]);   
  102.                         } // 打印棋盘
  103.                         printf("  ");
  104.                 }
  105.                 printf("\n");
  106.         }
  107. }
  108. void choose(void){
  109.         int count = 0;//判断是谁下棋
  110.         int row,col;
  111.         int end;//结束判断
  112.         do{
  113.                 if(count % 2 == 0){
  114.                         printf("请白棋落子!");
  115.                 }
  116.                 else{
  117.                         printf("请黑棋落子!");
  118.                 }
  119.                 printf("请输入要落子的坐标(行 列):");
  120.                 scanf("%d %d",&row,&col);
  121.                 if(count % 2 == 0){
  122.                         end = addWhite(row,col,count);
  123.                         count++;
  124.                 }
  125.                 else{
  126.                         end = addBlack(row,col,count);
  127.                         count++;
  128.                 }
  129.                 printChessBoard();
  130.                 if(end){
  131.                         break;
  132.                 }
  133.         }while(1);
  134. }
  135. int judge(int row,int col,int turn){
  136.         int N = 0,S = 0,E = 0,W = 0,NW = 0,NE = 0,SW = 0,SE = 0;
  137.         turn = turn % 2;
  138.         N = judge_N(row,col,turn);
  139.         S = judge_S(row,col,turn);
  140.         W = judge_W(row,col,turn);
  141.         E = judge_E(row,col,turn);
  142.         SW = judge_SW(row,col,turn);
  143.         SE = judge_SE(row,col,turn);
  144.         NW = judge_NW(row,col,turn);
  145.         NE = judge_NE(row,col,turn);
  146.         if(N + S >= 5 || W + E >= 5 || SW + NW >= 5 || NE + SE >=5){
  147.                 return 1;
  148.         }
  149.         return 0;
  150. }
  151. int judge_N(int row,int col,int turn){
  152.         int count_N = 0;
  153.         while(chessBoard[row--][col] == chess[turn] && row >= MIN){
  154.                 count_N++;
  155.         }
  156.         return count_N;
  157. }
  158. int judge_S(int row,int col,int turn){
  159.         int count_S = 0;
  160.         while(chessBoard[row++][col] == chess[turn] && row <= MAX){
  161.                 count_S++;
  162.         }
  163.         return count_S;
  164. }
  165. int judge_E(int row,int col,int turn){
  166.         int count_E = 0;
  167.         while(chessBoard[row][col++] == chess[turn] && col <= MAX){
  168.                 count_E++;
  169.         }
  170.         return count_E;
  171. }
  172. int judge_W(int row,int col,int turn){
  173.         int count_W = 0;
  174.         while(chessBoard[row][col--] == chess[turn] && col >= MIN){
  175.                 count_W++;
  176.         }
  177.         return count_W;
  178. }
  179. int judge_NW(int row,int col,int turn){
  180.         int count_NW = 0;
  181.         while(chessBoard[row++][col--] == chess[turn] && (row <= MAX && col >= MIN)){
  182.                 count_NW++;
  183.         }
  184.         return count_NW;
  185. }
  186. int judge_NE(int row,int col,int turn){
  187.         int count_NE = 0;
  188.         while(chessBoard[row++][col++] == chess[turn] && (row <= MAX && col <= MAX)){
  189.                 count_NE++;
  190.         }
  191.         return count_NE;
  192. }
  193. int judge_SE(int row,int col,int turn){
  194.         int count_SE = 0;
  195.         while(chessBoard[row--][col++] == chess[turn] && (row >= MIN && col <= MAX)){
  196.                 count_SE++;
  197.         }
  198.         return count_SE;
  199. }
  200. int judge_SW(int row,int col,int turn){
  201.         int count_SW = 0;
  202.         while(chessBoard[row--][col--] == chess[turn] && (row >= MIN && col >= MIN)){
  203.                 count_SW++;
  204.         }
  205.         return count_SW;
  206. }
复制代码

请黑棋落子!请输入要落子的坐标(行 列):1 5
黑棋获胜!
0   1   2   3   4   5   6   7   8   9  10  11  12  13
1   0   @   @   @   @   *   *   *   *   *   *   *   *
2   *   0   *   *   *   *   *   *   *   *   *   *   *
3   *   *   0   *   *   *   *   *   *   *   *   *   *
4   *   *   *   0   *   *   *   *   *   *   *   *   *
5   *   *   *   *   *   *   *   *   *   *   *   *   *
6   *   *   *   *   *   *   *   *   *   *   *   *   *
7   *   *   *   *   *   *   *   *   *   *   *   *   *
8   *   *   *   *   *   *   *   *   *   *   *   *   *
9   *   *   *   *   *   *   *   *   *   *   *   *   *
10   *   *   *   *   *   *   *   *   *   *   *   *   *
11   *   *   *   *   *   *   *   *   *   *   *   *   *
12   *   *   *   *   *   *   *   *   *   *   *   *   *
13   *   *   *   *   *   *   *   *   *   *   *   *   *

对了‘0’是表示白棋,‘@’是表示黑棋
最后有个这样的结果,大佬们看看咋办呐
最佳答案
2019-1-30 13:15:15
我知道问题了,你在判断的时候多加了一次
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>

  4. #define MAX 13
  5. #define MIN 1

  6. int addBlack(int row_in_fun, int col_in_fun, int count);
  7. int addWhite(int row_in_fun, int col_in_fun, int count);
  8. void cleanChessBoard(char* CB, int n);
  9. int judge(int row_in_fun, int col_in_fun, int trun);
  10. void printChessBoard(void);
  11. void choose(void);
  12. int judge_N(int row, int col, int turn);
  13. int judge_S(int row, int col, int turn);
  14. int judge_E(int row, int col, int turn);
  15. int judge_W(int row, int col, int turn);
  16. int judge_NW(int row, int col, int turn);
  17. int judge_NE(int row, int col, int turn);
  18. int judge_SE(int row, int col, int turn);
  19. int judge_SW(int row, int col, int turn);

  20. char chessBoard[14][14];
  21. char chess[2] = {'0', '@'};

  22. int main(){
  23.         //char tmp[14][14] = {
  24.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  25.         //        {0, 0, '@', '0', '@', '@', '@', '@', '0', 0, 0, 0, 0, 0},
  26.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  27.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  28.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  29.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  30.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  31.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  32.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  33.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  34.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  35.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  36.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  37.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  38.         //};
  39.         //
  40.         //memcpy(chessBoard, tmp, sizeof(tmp));
  41.         //printf("%d\n", judge(1, 2, 1));
  42.         //exit(1);
  43.        
  44.        
  45.         char *CB;
  46.         CB = &chessBoard[0][0];
  47.         cleanChessBoard(CB, 14);
  48.         choose();
  49.         return 0;
  50. }
  51. void cleanChessBoard(char* CB, int n){
  52.         int i, j;
  53.         for(i = 0; i < n; i++){  // n 为行
  54.                 for(j = 0; j < n; j++){ // j 为列

  55.                         if(i == 0){
  56.                                 printf("%2d", j); // 第一行打印棋盘上面的数字坐标

  57.                         }
  58.                         else if(j == 0 && i != 0){ //每一行的开头打印列标
  59.                                 printf("%2d", i);
  60.                         }
  61.                         else{
  62.                                 printf(" ");
  63.                                 *(CB + i * n + j) = '*';       //未落子的区域打印 * 表明未落子;
  64.                                 printf("%c", chessBoard[i][j]);
  65.                         } // 打印棋盘
  66.                         printf("  ");
  67.                 }
  68.                 printf("\n");
  69.         }
  70. }
  71. int addBlack(int row_in_fun, int col_in_fun, int count){
  72.         int flag;//接收judge的返回值,判断是否结束比赛
  73.         if(chessBoard[row_in_fun][col_in_fun] == '*'){   //判断该区域是否已经落了子
  74.                 chessBoard[row_in_fun][col_in_fun] = '@';
  75.                 flag = judge(row_in_fun, col_in_fun, count);
  76.                 if(flag){
  77.                         printf("黑棋获胜!\n");
  78.                         return 1;
  79.                 }
  80.         }
  81.         else{
  82.                 printf("这里有棋子了!");
  83.                 printf("重新输入坐标:");
  84.                 int row, col;
  85.                 scanf("%d %d", &row, &col);
  86.                 addBlack(row, col, count);
  87.         }
  88.         return 0;
  89. }
  90. int addWhite(int row_in_fun, int col_in_fun, int count){
  91.         int flag;//接收judge的返回值,判断是否结束比赛
  92.         if(chessBoard[row_in_fun][col_in_fun] == '*'){
  93.                 chessBoard[row_in_fun][col_in_fun] = '0';
  94.                 flag = judge(row_in_fun, col_in_fun, count);
  95.                 if(flag){
  96.                         printf("白棋获胜!\n");
  97.                         return 1;
  98.                 }
  99.         }
  100.         else{
  101.                 printf("这里有棋子了!");
  102.                 printf("重新输入坐标:");
  103.                 int row, col;
  104.                 scanf("%d %d", &row, &col);
  105.                 addWhite(row, col, count);
  106.         }
  107.         return 0;
  108. }
  109. void printChessBoard(void){
  110.         int i, j;
  111.         for(i = 0; i < 14; i++){  // n 为行
  112.                 for(j = 0; j < 14; j++){ // j 为列

  113.                         if(i == 0){
  114.                                 printf("%2d", j); // 第一行打印棋盘上面的数字坐标

  115.                         }
  116.                         else if(j == 0 && i != 0){ //每一行的开头打印列标
  117.                                 printf("%2d", i);
  118.                         }
  119.                         else{
  120.                                 printf(" ");
  121.                                 printf("%c", chessBoard[i][j]);
  122.                         } // 打印棋盘
  123.                         printf("  ");
  124.                 }
  125.                 printf("\n");
  126.         }
  127. }
  128. void choose(void){
  129.         int count = 0;//判断是谁下棋
  130.         int row, col;
  131.         int end;//结束判断
  132.         do{
  133.                 if(count % 2 == 0){
  134.                         printf("请白棋落子!");
  135.                 }
  136.                 else{
  137.                         printf("请黑棋落子!");
  138.                 }
  139.                 printf("请输入要落子的坐标(行 列):");
  140.                 scanf("%d %d", &row, &col);
  141.                 if(count % 2 == 0){
  142.                         end = addWhite(row, col, count);
  143.                         count++;
  144.                 }
  145.                 else{
  146.                         end = addBlack(row, col, count);
  147.                         count++;
  148.                 }
  149.                 printChessBoard();
  150.                 if(end){
  151.                         break;
  152.                 }
  153.         }
  154.         while(1);
  155. }

  156. int judge(int row, int col, int turn){
  157.         int N = 0, S = 0, E = 0, W = 0, NW = 0, NE = 0, SW = 0, SE = 0;
  158.         turn = turn % 2;
  159.         N = judge_N(row, col, turn);
  160.         S = judge_S(row, col, turn);
  161.         W = judge_W(row, col, turn);
  162.         E = judge_E(row, col, turn);
  163.         SW = judge_SW(row, col, turn);
  164.         SE = judge_SE(row, col, turn);
  165.         NW = judge_NW(row, col, turn);
  166.         NE = judge_NE(row, col, turn);
  167.         if(N + S >= 5 || W + E >= 5 || SW + NW >= 5 || NE + SE >= 5){
  168.                 return 1;
  169.         }
  170.         return 0;
  171. }
  172. int judge_N(int row, int col, int turn){
  173.         int count_N = 0;
  174.         while(chessBoard[row--][col] == chess[turn] && row >= MIN){
  175.                 count_N++;
  176.         }
  177.         return count_N;
  178. }
  179. int judge_S(int row, int col, int turn){
  180.         int count_S = 0;
  181.         while(chessBoard[++row][col] == chess[turn] && row <= MAX){
  182.                 count_S++;
  183.         }
  184.         return count_S;
  185. }
  186. int judge_E(int row, int col, int turn){
  187.         int count_E = 0;
  188.         while(chessBoard[row][col++] == chess[turn] && col <= MAX){
  189.                 count_E++;
  190.         }
  191.         return count_E;
  192. }
  193. int judge_W(int row, int col, int turn){
  194.         int count_W = 0;
  195.         while(chessBoard[row][--col] == chess[turn] && col >= MIN){
  196.                 count_W++;
  197.         }
  198.         return count_W;
  199. }
  200. int judge_NW(int row, int col, int turn){
  201.         int count_NW = 0;
  202.         while(chessBoard[row++][col--] == chess[turn] && (row <= MAX && col >= MIN)){
  203.                 count_NW++;
  204.         }
  205.         return count_NW;
  206. }
  207. int judge_NE(int row, int col, int turn){
  208.         int count_NE = 0;
  209.         while(chessBoard[++row][++col] == chess[turn] && (row <= MAX && col <= MAX)){
  210.                 count_NE++;
  211.         }
  212.         return count_NE;
  213. }
  214. int judge_SE(int row, int col, int turn){
  215.         int count_SE = 0;
  216.         while(chessBoard[row--][col++] == chess[turn] && (row >= MIN && col <= MAX)){
  217.                 count_SE++;
  218.         }
  219.         return count_SE;
  220. }
  221. int judge_SW(int row, int col, int turn){
  222.         int count_SW = 0;
  223.         while(chessBoard[--row][--col] == chess[turn] && (row >= MIN && col >= MIN)){
  224.                 count_SW++;
  225.         }
  226.         return count_SW;
  227. }
复制代码


  1. int judge(int row, int col, int turn){
  2.         int N = 0, S = 0, E = 0, W = 0, NW = 0, NE = 0, SW = 0, SE = 0;
  3.         turn = turn % 2;
  4.         N = judge_N(row, col, turn);
  5.         S = judge_S(row, col, turn);
  6.         W = judge_W(row, col, turn);
  7.         E = judge_E(row, col, turn);
  8.         SW = judge_SW(row, col, turn);
  9.         SE = judge_SE(row, col, turn);
  10.         NW = judge_NW(row, col, turn);
  11.         NE = judge_NE(row, col, turn);
  12.         if(N + S >= 5 || W + E >= 5 || SW + NW >= 5 || NE + SE >= 5){
  13.                 return 1;
  14.         }
  15.         return 0;
  16. }
  17. int judge_N(int row, int col, int turn){
  18.         int count_N = 0;
  19.         while(chessBoard[row--][col] == chess[turn] && row >= MIN){
  20.                 count_N++;
  21.         }
  22.         return count_N;
  23. }
  24. int judge_S(int row, int col, int turn){
  25.         int count_S = 0;
  26.         while(chessBoard[++row][col] == chess[turn] && row <= MAX){
  27.                 count_S++;
  28.         }
  29.         return count_S;
  30. }
  31. int judge_E(int row, int col, int turn){
  32.         int count_E = 0;
  33.         while(chessBoard[row][col++] == chess[turn] && col <= MAX){
  34.                 count_E++;
  35.         }
  36.         return count_E;
  37. }
  38. int judge_W(int row, int col, int turn){
  39.         int count_W = 0;
  40.         while(chessBoard[row][--col] == chess[turn] && col >= MIN){
  41.                 count_W++;
  42.         }
  43.         return count_W;
  44. }
  45. int judge_NW(int row, int col, int turn){
  46.         int count_NW = 0;
  47.         while(chessBoard[row++][col--] == chess[turn] && (row <= MAX && col >= MIN)){
  48.                 count_NW++;
  49.         }
  50.         return count_NW;
  51. }
  52. int judge_NE(int row, int col, int turn){
  53.         int count_NE = 0;
  54.         while(chessBoard[++row][++col] == chess[turn] && (row <= MAX && col <= MAX)){
  55.                 count_NE++;
  56.         }
  57.         return count_NE;
  58. }
  59. int judge_SE(int row, int col, int turn){
  60.         int count_SE = 0;
  61.         while(chessBoard[row--][col++] == chess[turn] && (row >= MIN && col <= MAX)){
  62.                 count_SE++;
  63.         }
  64.         return count_SE;
  65. }
  66. int judge_SW(int row, int col, int turn){
  67.         int count_SW = 0;
  68.         while(chessBoard[--row][--col] == chess[turn] && (row >= MIN && col >= MIN)){
  69.                 count_SW++;
  70.         }
  71.         return count_SW;
  72. }
复制代码

  1. int judge(int row,int col,int turn){
  2.         int N = 0,S = 0,E = 0,W = 0,NW = 0,NE = 0,SW = 0,SE = 0;
  3.         turn = turn % 2;
  4.         N = judge_N(row,col,turn);
  5.         S = judge_S(row,col,turn);
  6.         W = judge_W(row,col,turn);
  7.         E = judge_E(row,col,turn);
  8.         SW = judge_SW(row,col,turn);
  9.         SE = judge_SE(row,col,turn);
  10.         NW = judge_NW(row,col,turn);
  11.         NE = judge_NE(row,col,turn);
  12.         if(N + S >= 5 || W + E >= 5 || SW + NW >= 5 || NE + SE >=5){
  13.                 return 1;
  14.         }
  15.         return 0;
  16. }
  17. int judge_N(int row,int col,int turn){
  18.         int count_N = 0;
  19.         while(chessBoard[row--][col] == chess[turn] && row >= MIN){
  20.                 count_N++;
  21.         }
  22.         return count_N;
  23. }
  24. int judge_S(int row,int col,int turn){
  25.         int count_S = 0;
  26.         while(chessBoard[row++][col] == chess[turn] && row <= MAX){
  27.                 count_S++;
  28.         }
  29.         return count_S;
  30. }
  31. int judge_E(int row,int col,int turn){
  32.         int count_E = 0;
  33.         while(chessBoard[row][col++] == chess[turn] && col <= MAX){
  34.                 count_E++;
  35.         }
  36.         return count_E;
  37. }
  38. int judge_W(int row,int col,int turn){
  39.         int count_W = 0;
  40.         while(chessBoard[row][col--] == chess[turn] && col >= MIN){
  41.                 count_W++;
  42.         }
  43.         return count_W;
  44. }
  45. int judge_NW(int row,int col,int turn){
  46.         int count_NW = 0;
  47.         while(chessBoard[row++][col--] == chess[turn] && (row <= MAX && col >= MIN)){
  48.                 count_NW++;
  49.         }
  50.         return count_NW;
  51. }
  52. int judge_NE(int row,int col,int turn){
  53.         int count_NE = 0;
  54.         while(chessBoard[row++][col++] == chess[turn] && (row <= MAX && col <= MAX)){
  55.                 count_NE++;
  56.         }
  57.         return count_NE;
  58. }
  59. int judge_SE(int row,int col,int turn){
  60.         int count_SE = 0;
  61.         while(chessBoard[row--][col++] == chess[turn] && (row >= MIN && col <= MAX)){
  62.                 count_SE++;
  63.         }
  64.         return count_SE;
  65. }
  66. int judge_SW(int row,int col,int turn){
  67.         int count_SW = 0;
  68.         while(chessBoard[row--][col--] == chess[turn] && (row >= MIN && col >= MIN)){
  69.                 count_SW++;
  70.         }
  71.         return count_SW;
  72. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2019-1-29 21:26:32 | 显示全部楼层
judge函数逻辑错误

  1. #include <stdio.h>
  2. #include <string.h>

  3. #define MAX 13
  4. #define MIN 1

  5. int addBlack(int row_in_fun, int col_in_fun, int count);
  6. int addWhite(int row_in_fun, int col_in_fun, int count);
  7. void cleanChessBoard(char* CB, int n);
  8. //int judge(int row_in_fun, int col_in_fun, int trun);
  9. int judge(int turn);
  10. void printChessBoard(void);
  11. void choose(void);
  12. //int judge_N(int row, int col, int turn);
  13. //int judge_S(int row, int col, int turn);
  14. //int judge_E(int row, int col, int turn);
  15. //int judge_W(int row, int col, int turn);
  16. //int judge_NW(int row, int col, int turn);
  17. //int judge_NE(int row, int col, int turn);
  18. //int judge_SE(int row, int col, int turn);
  19. //int judge_SW(int row, int col, int turn);

  20. char chessBoard[14][14];
  21. char chess[2] = {'0', '@'};

  22. int main(){
  23.         char *CB;
  24.         CB = &chessBoard[0][0];
  25.         cleanChessBoard(CB, 14);
  26.         choose();
  27.         return 0;
  28. }
  29. void cleanChessBoard(char* CB, int n){
  30.         int i, j;
  31.         for(i = 0; i < n; i++){  // n 为行
  32.                 for(j = 0; j < n; j++){ // j 为列

  33.                         if(i == 0){
  34.                                 printf("%2d", j); // 第一行打印棋盘上面的数字坐标

  35.                         }
  36.                         else if(j == 0 && i != 0){ //每一行的开头打印列标
  37.                                 printf("%2d", i);
  38.                         }
  39.                         else{
  40.                                 printf(" ");
  41.                                 *(CB + i * n + j) = '*';       //未落子的区域打印 * 表明未落子;
  42.                                 printf("%c", chessBoard[i][j]);
  43.                         } // 打印棋盘
  44.                         printf("  ");
  45.                 }
  46.                 printf("\n");
  47.         }
  48. }
  49. int addBlack(int row_in_fun, int col_in_fun, int count){
  50.         int flag;//接收judge的返回值,判断是否结束比赛
  51.         if(chessBoard[row_in_fun][col_in_fun] == '*'){   //判断该区域是否已经落了子
  52.                 chessBoard[row_in_fun][col_in_fun] = '@';
  53.                 flag = judge(count % 2);
  54.                 if(flag){
  55.                         printf("黑棋获胜!\n");
  56.                         return 1;
  57.                 }
  58.         }
  59.         else{
  60.                 printf("这里有棋子了!");
  61.                 printf("重新输入坐标:");
  62.                 int row, col;
  63.                 scanf("%d %d", &row, &col);
  64.                 addBlack(row, col, count);
  65.         }
  66.         return 0;
  67. }
  68. int addWhite(int row_in_fun, int col_in_fun, int count){
  69.         int flag;//接收judge的返回值,判断是否结束比赛
  70.         if(chessBoard[row_in_fun][col_in_fun] == '*'){
  71.                 chessBoard[row_in_fun][col_in_fun] = '0';
  72.                 flag = judge(count % 2);
  73.                 if(flag){
  74.                         printf("白棋获胜!\n");
  75.                         return 1;
  76.                 }
  77.         }
  78.         else{
  79.                 printf("这里有棋子了!");
  80.                 printf("重新输入坐标:");
  81.                 int row, col;
  82.                 scanf("%d %d", &row, &col);
  83.                 addWhite(row, col, count);
  84.         }
  85.         return 0;
  86. }
  87. void printChessBoard(void){
  88.         int i, j;
  89.         for(i = 0; i < 14; i++){  // n 为行
  90.                 for(j = 0; j < 14; j++){ // j 为列

  91.                         if(i == 0){
  92.                                 printf("%2d", j); // 第一行打印棋盘上面的数字坐标

  93.                         }
  94.                         else if(j == 0 && i != 0){ //每一行的开头打印列标
  95.                                 printf("%2d", i);
  96.                         }
  97.                         else{
  98.                                 printf(" ");
  99.                                 printf("%c", chessBoard[i][j]);
  100.                         } // 打印棋盘
  101.                         printf("  ");
  102.                 }
  103.                 printf("\n");
  104.         }
  105. }
  106. void choose(void){
  107.         int count = 0;//判断是谁下棋
  108.         int row, col;
  109.         int end;//结束判断
  110.         do{
  111.                 if(count % 2 == 0){
  112.                         printf("请白棋落子!");
  113.                 }
  114.                 else{
  115.                         printf("请黑棋落子!");
  116.                 }
  117.                 printf("请输入要落子的坐标(行 列):");
  118.                 scanf("%d %d", &row, &col);
  119.                 if(count % 2 == 0){
  120.                         end = addWhite(row, col, count);
  121.                         count++;
  122.                 }
  123.                 else{
  124.                         end = addBlack(row, col, count);
  125.                         count++;
  126.                 }
  127.                 printChessBoard();
  128.                 if(end){
  129.                         break;
  130.                 }
  131.         }
  132.         while(1);
  133. }

  134. int judge(int turn)
  135. {
  136.         for(int y = MIN; y <= MAX; ++y)                // 每一行
  137.         {
  138.                 for(int x = MIN; x <= MAX - 4; ++x)
  139.                 {
  140.                         if(chessBoard[y][x] == chess[turn]
  141.                                 && chessBoard[y][x + 1] == chess[turn]
  142.                                 && chessBoard[y][x + 2] == chess[turn]
  143.                                 && chessBoard[y][x + 3] == chess[turn]
  144.                                 && chessBoard[y][x + 4] == chess[turn])
  145.                         {
  146.                                 return 1;
  147.                         }
  148.                 }
  149.         }

  150.         for(int x = MIN; x <= MAX; ++x)                // 每一列
  151.         {
  152.                 for(int y = MIN; y <= MAX - 4; ++y)
  153.                 {
  154.                         if(chessBoard[y][x] == chess[turn]
  155.                                 && chessBoard[y + 1][x] == chess[turn]
  156.                                 && chessBoard[y + 2][x] == chess[turn]
  157.                                 && chessBoard[y + 3][x] == chess[turn]
  158.                                 && chessBoard[y + 4][x] == chess[turn])
  159.                         {
  160.                                 return 1;
  161.                         }
  162.                 }
  163.         }

  164.         int tmp[MAX + 1][MAX + 1];
  165.         memset(tmp, 0, sizeof(tmp));
  166.         for(int y = MIN; y <= MAX; ++y)                // 左下角到右上角的斜线的一半
  167.         {
  168.                 int index = 1;
  169.                 for(int a = y, x = MIN; a >= 1; --a, ++x)
  170.                         tmp[y][index++] = chessBoard[a][x];
  171.         }
  172.         for(int y = MIN; y <= MAX; ++y)                // 验证
  173.         {
  174.                 for(int x = MIN; x <= MAX - 4; ++x)
  175.                 {
  176.                         if(tmp[y][x] == chess[turn]
  177.                                 && tmp[y][x + 1] == chess[turn]
  178.                                 && tmp[y][x + 2] == chess[turn]
  179.                                 && tmp[y][x + 3] == chess[turn]
  180.                                 && tmp[y][x + 4] == chess[turn])
  181.                         {
  182.                                 return 1;
  183.                         }
  184.                 }
  185.         }
  186.         memset(tmp, 0, sizeof(tmp));
  187.         for(int y = MIN; y <= MAX; ++y)                // 左下角到右上角的斜线的另一半
  188.         {
  189.                 int index = 1;
  190.                 for(int a = y, x = MAX; a <= MAX; ++a, --x)
  191.                         tmp[y][index++] = chessBoard[a][x];
  192.         }
  193.         for(int y = MIN; y <= MAX; ++y)                // 验证
  194.         {
  195.                 for(int x = MIN; x <= MAX - 4; ++x)
  196.                 {
  197.                         if(tmp[y][x] == chess[turn]
  198.                                 && tmp[y][x + 1] == chess[turn]
  199.                                 && tmp[y][x + 2] == chess[turn]
  200.                                 && tmp[y][x + 3] == chess[turn]
  201.                                 && tmp[y][x + 4] == chess[turn])
  202.                         {
  203.                                 return 1;
  204.                         }
  205.                 }
  206.         }

  207.         memset(tmp, 0, sizeof(tmp));
  208.         for(int y = MIN; y <= MAX; ++y)                // 左上角到右下角的斜线的一半
  209.         {
  210.                 int index = 1;
  211.                 for(int a = y, x = MIN; a <= MAX; ++a, ++x)
  212.                         tmp[y][index++] = chessBoard[a][x];
  213.         }
  214.         for(int y = MIN; y <= MAX; ++y)                // 验证
  215.         {
  216.                 for(int x = MIN; x <= MAX - 4; ++x)
  217.                 {
  218.                         if(tmp[y][x] == chess[turn]
  219.                                 && tmp[y][x + 1] == chess[turn]
  220.                                 && tmp[y][x + 2] == chess[turn]
  221.                                 && tmp[y][x + 3] == chess[turn]
  222.                                 && tmp[y][x + 4] == chess[turn])
  223.                         {
  224.                                 return 1;
  225.                         }
  226.                 }
  227.         }
  228.         memset(tmp, 0, sizeof(tmp));
  229.         for(int y = MIN; y <= MAX; ++y)                // 左上角到右下角的斜线的另一半
  230.         {
  231.                 int index = 1;
  232.                 for(int a = y, x = MAX; a >= 1; --a, --x)
  233.                         tmp[y][index++] = chessBoard[a][x];
  234.         }
  235.         for(int y = MIN; y <= MAX; ++y)                // 验证
  236.         {
  237.                 for(int x = MIN; x <= MAX - 4; ++x)
  238.                 {
  239.                         if(tmp[y][x] == chess[turn]
  240.                                 && tmp[y][x + 1] == chess[turn]
  241.                                 && tmp[y][x + 2] == chess[turn]
  242.                                 && tmp[y][x + 3] == chess[turn]
  243.                                 && tmp[y][x + 4] == chess[turn])
  244.                         {
  245.                                 return 1;
  246.                         }
  247.                 }
  248.         }
  249.         return 0;
  250. }

  251. //int judge(int row, int col, int turn){
  252. //        int N = 0, S = 0, E = 0, W = 0, NW = 0, NE = 0, SW = 0, SE = 0;
  253. //        turn = turn % 2;
  254. //        N = judge_N(row, col, turn);
  255. //        S = judge_S(row, col, turn);
  256. //        W = judge_W(row, col, turn);
  257. //        E = judge_E(row, col, turn);
  258. //        SW = judge_SW(row, col, turn);
  259. //        SE = judge_SE(row, col, turn);
  260. //        NW = judge_NW(row, col, turn);
  261. //        NE = judge_NE(row, col, turn);
  262. //        if(N + S >= 5 || W + E >= 5 || SW + NW >= 5 || NE + SE >= 5){
  263. //                return 1;
  264. //        }
  265. //        return 0;
  266. //}
  267. //int judge_N(int row, int col, int turn){
  268. //        int count_N = 0;
  269. //        while(chessBoard[row--][col] == chess[turn] && row >= MIN){
  270. //                count_N++;
  271. //        }
  272. //        return count_N;
  273. //}
  274. //int judge_S(int row, int col, int turn){
  275. //        int count_S = 0;
  276. //        while(chessBoard[row++][col] == chess[turn] && row <= MAX){
  277. //                count_S++;
  278. //        }
  279. //        return count_S;
  280. //}
  281. //int judge_E(int row, int col, int turn){
  282. //        int count_E = 0;
  283. //        while(chessBoard[row][col++] == chess[turn] && col <= MAX){
  284. //                count_E++;
  285. //        }
  286. //        return count_E;
  287. //}
  288. //int judge_W(int row, int col, int turn){
  289. //        int count_W = 0;
  290. //        while(chessBoard[row][col--] == chess[turn] && col >= MIN){
  291. //                count_W++;
  292. //        }
  293. //        return count_W;
  294. //}
  295. //int judge_NW(int row, int col, int turn){
  296. //        int count_NW = 0;
  297. //        while(chessBoard[row++][col--] == chess[turn] && (row <= MAX && col >= MIN)){
  298. //                count_NW++;
  299. //        }
  300. //        return count_NW;
  301. //}
  302. //int judge_NE(int row, int col, int turn){
  303. //        int count_NE = 0;
  304. //        while(chessBoard[row++][col++] == chess[turn] && (row <= MAX && col <= MAX)){
  305. //                count_NE++;
  306. //        }
  307. //        return count_NE;
  308. //}
  309. //int judge_SE(int row, int col, int turn){
  310. //        int count_SE = 0;
  311. //        while(chessBoard[row--][col++] == chess[turn] && (row >= MIN && col <= MAX)){
  312. //                count_SE++;
  313. //        }
  314. //        return count_SE;
  315. //}
  316. //int judge_SW(int row, int col, int turn){
  317. //        int count_SW = 0;
  318. //        while(chessBoard[row--][col--] == chess[turn] && (row >= MIN && col >= MIN)){
  319. //                count_SW++;
  320. //        }
  321. //        return count_SW;
  322. //}
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-30 09:51:39 | 显示全部楼层
emm,大佬能否说说我的逻辑错误是怎样的?还有就是大佬这个是搜索整个棋盘的,这样是不是有点费时呢?
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-1-30 12:46:19 | 显示全部楼层
cookies945 发表于 2019-1-30 09:51
emm,大佬能否说说我的逻辑错误是怎样的?还有就是大佬这个是搜索整个棋盘的,这样是不是有点费时呢?

五子棋的规则是什么?
在每条横线,每条竖线,还有斜线
只要有连续的5个棋子,就结束游戏,达成这一目的方获胜

你的代码逻辑是
在每条横线,每条竖线,还有斜线上只要有5个相同的棋子就行了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-1-30 13:03:15 | 显示全部楼层
等一等,我再看一看你的代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-1-30 13:15:15 | 显示全部楼层    本楼为最佳答案   
我知道问题了,你在判断的时候多加了一次
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>

  4. #define MAX 13
  5. #define MIN 1

  6. int addBlack(int row_in_fun, int col_in_fun, int count);
  7. int addWhite(int row_in_fun, int col_in_fun, int count);
  8. void cleanChessBoard(char* CB, int n);
  9. int judge(int row_in_fun, int col_in_fun, int trun);
  10. void printChessBoard(void);
  11. void choose(void);
  12. int judge_N(int row, int col, int turn);
  13. int judge_S(int row, int col, int turn);
  14. int judge_E(int row, int col, int turn);
  15. int judge_W(int row, int col, int turn);
  16. int judge_NW(int row, int col, int turn);
  17. int judge_NE(int row, int col, int turn);
  18. int judge_SE(int row, int col, int turn);
  19. int judge_SW(int row, int col, int turn);

  20. char chessBoard[14][14];
  21. char chess[2] = {'0', '@'};

  22. int main(){
  23.         //char tmp[14][14] = {
  24.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  25.         //        {0, 0, '@', '0', '@', '@', '@', '@', '0', 0, 0, 0, 0, 0},
  26.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  27.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  28.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  29.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  30.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  31.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  32.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  33.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  34.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  35.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  36.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  37.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  38.         //};
  39.         //
  40.         //memcpy(chessBoard, tmp, sizeof(tmp));
  41.         //printf("%d\n", judge(1, 2, 1));
  42.         //exit(1);
  43.        
  44.        
  45.         char *CB;
  46.         CB = &chessBoard[0][0];
  47.         cleanChessBoard(CB, 14);
  48.         choose();
  49.         return 0;
  50. }
  51. void cleanChessBoard(char* CB, int n){
  52.         int i, j;
  53.         for(i = 0; i < n; i++){  // n 为行
  54.                 for(j = 0; j < n; j++){ // j 为列

  55.                         if(i == 0){
  56.                                 printf("%2d", j); // 第一行打印棋盘上面的数字坐标

  57.                         }
  58.                         else if(j == 0 && i != 0){ //每一行的开头打印列标
  59.                                 printf("%2d", i);
  60.                         }
  61.                         else{
  62.                                 printf(" ");
  63.                                 *(CB + i * n + j) = '*';       //未落子的区域打印 * 表明未落子;
  64.                                 printf("%c", chessBoard[i][j]);
  65.                         } // 打印棋盘
  66.                         printf("  ");
  67.                 }
  68.                 printf("\n");
  69.         }
  70. }
  71. int addBlack(int row_in_fun, int col_in_fun, int count){
  72.         int flag;//接收judge的返回值,判断是否结束比赛
  73.         if(chessBoard[row_in_fun][col_in_fun] == '*'){   //判断该区域是否已经落了子
  74.                 chessBoard[row_in_fun][col_in_fun] = '@';
  75.                 flag = judge(row_in_fun, col_in_fun, count);
  76.                 if(flag){
  77.                         printf("黑棋获胜!\n");
  78.                         return 1;
  79.                 }
  80.         }
  81.         else{
  82.                 printf("这里有棋子了!");
  83.                 printf("重新输入坐标:");
  84.                 int row, col;
  85.                 scanf("%d %d", &row, &col);
  86.                 addBlack(row, col, count);
  87.         }
  88.         return 0;
  89. }
  90. int addWhite(int row_in_fun, int col_in_fun, int count){
  91.         int flag;//接收judge的返回值,判断是否结束比赛
  92.         if(chessBoard[row_in_fun][col_in_fun] == '*'){
  93.                 chessBoard[row_in_fun][col_in_fun] = '0';
  94.                 flag = judge(row_in_fun, col_in_fun, count);
  95.                 if(flag){
  96.                         printf("白棋获胜!\n");
  97.                         return 1;
  98.                 }
  99.         }
  100.         else{
  101.                 printf("这里有棋子了!");
  102.                 printf("重新输入坐标:");
  103.                 int row, col;
  104.                 scanf("%d %d", &row, &col);
  105.                 addWhite(row, col, count);
  106.         }
  107.         return 0;
  108. }
  109. void printChessBoard(void){
  110.         int i, j;
  111.         for(i = 0; i < 14; i++){  // n 为行
  112.                 for(j = 0; j < 14; j++){ // j 为列

  113.                         if(i == 0){
  114.                                 printf("%2d", j); // 第一行打印棋盘上面的数字坐标

  115.                         }
  116.                         else if(j == 0 && i != 0){ //每一行的开头打印列标
  117.                                 printf("%2d", i);
  118.                         }
  119.                         else{
  120.                                 printf(" ");
  121.                                 printf("%c", chessBoard[i][j]);
  122.                         } // 打印棋盘
  123.                         printf("  ");
  124.                 }
  125.                 printf("\n");
  126.         }
  127. }
  128. void choose(void){
  129.         int count = 0;//判断是谁下棋
  130.         int row, col;
  131.         int end;//结束判断
  132.         do{
  133.                 if(count % 2 == 0){
  134.                         printf("请白棋落子!");
  135.                 }
  136.                 else{
  137.                         printf("请黑棋落子!");
  138.                 }
  139.                 printf("请输入要落子的坐标(行 列):");
  140.                 scanf("%d %d", &row, &col);
  141.                 if(count % 2 == 0){
  142.                         end = addWhite(row, col, count);
  143.                         count++;
  144.                 }
  145.                 else{
  146.                         end = addBlack(row, col, count);
  147.                         count++;
  148.                 }
  149.                 printChessBoard();
  150.                 if(end){
  151.                         break;
  152.                 }
  153.         }
  154.         while(1);
  155. }

  156. int judge(int row, int col, int turn){
  157.         int N = 0, S = 0, E = 0, W = 0, NW = 0, NE = 0, SW = 0, SE = 0;
  158.         turn = turn % 2;
  159.         N = judge_N(row, col, turn);
  160.         S = judge_S(row, col, turn);
  161.         W = judge_W(row, col, turn);
  162.         E = judge_E(row, col, turn);
  163.         SW = judge_SW(row, col, turn);
  164.         SE = judge_SE(row, col, turn);
  165.         NW = judge_NW(row, col, turn);
  166.         NE = judge_NE(row, col, turn);
  167.         if(N + S >= 5 || W + E >= 5 || SW + NW >= 5 || NE + SE >= 5){
  168.                 return 1;
  169.         }
  170.         return 0;
  171. }
  172. int judge_N(int row, int col, int turn){
  173.         int count_N = 0;
  174.         while(chessBoard[row--][col] == chess[turn] && row >= MIN){
  175.                 count_N++;
  176.         }
  177.         return count_N;
  178. }
  179. int judge_S(int row, int col, int turn){
  180.         int count_S = 0;
  181.         while(chessBoard[++row][col] == chess[turn] && row <= MAX){
  182.                 count_S++;
  183.         }
  184.         return count_S;
  185. }
  186. int judge_E(int row, int col, int turn){
  187.         int count_E = 0;
  188.         while(chessBoard[row][col++] == chess[turn] && col <= MAX){
  189.                 count_E++;
  190.         }
  191.         return count_E;
  192. }
  193. int judge_W(int row, int col, int turn){
  194.         int count_W = 0;
  195.         while(chessBoard[row][--col] == chess[turn] && col >= MIN){
  196.                 count_W++;
  197.         }
  198.         return count_W;
  199. }
  200. int judge_NW(int row, int col, int turn){
  201.         int count_NW = 0;
  202.         while(chessBoard[row++][col--] == chess[turn] && (row <= MAX && col >= MIN)){
  203.                 count_NW++;
  204.         }
  205.         return count_NW;
  206. }
  207. int judge_NE(int row, int col, int turn){
  208.         int count_NE = 0;
  209.         while(chessBoard[++row][++col] == chess[turn] && (row <= MAX && col <= MAX)){
  210.                 count_NE++;
  211.         }
  212.         return count_NE;
  213. }
  214. int judge_SE(int row, int col, int turn){
  215.         int count_SE = 0;
  216.         while(chessBoard[row--][col++] == chess[turn] && (row >= MIN && col <= MAX)){
  217.                 count_SE++;
  218.         }
  219.         return count_SE;
  220. }
  221. int judge_SW(int row, int col, int turn){
  222.         int count_SW = 0;
  223.         while(chessBoard[--row][--col] == chess[turn] && (row >= MIN && col >= MIN)){
  224.                 count_SW++;
  225.         }
  226.         return count_SW;
  227. }
复制代码


  1. int judge(int row, int col, int turn){
  2.         int N = 0, S = 0, E = 0, W = 0, NW = 0, NE = 0, SW = 0, SE = 0;
  3.         turn = turn % 2;
  4.         N = judge_N(row, col, turn);
  5.         S = judge_S(row, col, turn);
  6.         W = judge_W(row, col, turn);
  7.         E = judge_E(row, col, turn);
  8.         SW = judge_SW(row, col, turn);
  9.         SE = judge_SE(row, col, turn);
  10.         NW = judge_NW(row, col, turn);
  11.         NE = judge_NE(row, col, turn);
  12.         if(N + S >= 5 || W + E >= 5 || SW + NW >= 5 || NE + SE >= 5){
  13.                 return 1;
  14.         }
  15.         return 0;
  16. }
  17. int judge_N(int row, int col, int turn){
  18.         int count_N = 0;
  19.         while(chessBoard[row--][col] == chess[turn] && row >= MIN){
  20.                 count_N++;
  21.         }
  22.         return count_N;
  23. }
  24. int judge_S(int row, int col, int turn){
  25.         int count_S = 0;
  26.         while(chessBoard[++row][col] == chess[turn] && row <= MAX){
  27.                 count_S++;
  28.         }
  29.         return count_S;
  30. }
  31. int judge_E(int row, int col, int turn){
  32.         int count_E = 0;
  33.         while(chessBoard[row][col++] == chess[turn] && col <= MAX){
  34.                 count_E++;
  35.         }
  36.         return count_E;
  37. }
  38. int judge_W(int row, int col, int turn){
  39.         int count_W = 0;
  40.         while(chessBoard[row][--col] == chess[turn] && col >= MIN){
  41.                 count_W++;
  42.         }
  43.         return count_W;
  44. }
  45. int judge_NW(int row, int col, int turn){
  46.         int count_NW = 0;
  47.         while(chessBoard[row++][col--] == chess[turn] && (row <= MAX && col >= MIN)){
  48.                 count_NW++;
  49.         }
  50.         return count_NW;
  51. }
  52. int judge_NE(int row, int col, int turn){
  53.         int count_NE = 0;
  54.         while(chessBoard[++row][++col] == chess[turn] && (row <= MAX && col <= MAX)){
  55.                 count_NE++;
  56.         }
  57.         return count_NE;
  58. }
  59. int judge_SE(int row, int col, int turn){
  60.         int count_SE = 0;
  61.         while(chessBoard[row--][col++] == chess[turn] && (row >= MIN && col <= MAX)){
  62.                 count_SE++;
  63.         }
  64.         return count_SE;
  65. }
  66. int judge_SW(int row, int col, int turn){
  67.         int count_SW = 0;
  68.         while(chessBoard[--row][--col] == chess[turn] && (row >= MIN && col >= MIN)){
  69.                 count_SW++;
  70.         }
  71.         return count_SW;
  72. }
复制代码

  1. int judge(int row,int col,int turn){
  2.         int N = 0,S = 0,E = 0,W = 0,NW = 0,NE = 0,SW = 0,SE = 0;
  3.         turn = turn % 2;
  4.         N = judge_N(row,col,turn);
  5.         S = judge_S(row,col,turn);
  6.         W = judge_W(row,col,turn);
  7.         E = judge_E(row,col,turn);
  8.         SW = judge_SW(row,col,turn);
  9.         SE = judge_SE(row,col,turn);
  10.         NW = judge_NW(row,col,turn);
  11.         NE = judge_NE(row,col,turn);
  12.         if(N + S >= 5 || W + E >= 5 || SW + NW >= 5 || NE + SE >=5){
  13.                 return 1;
  14.         }
  15.         return 0;
  16. }
  17. int judge_N(int row,int col,int turn){
  18.         int count_N = 0;
  19.         while(chessBoard[row--][col] == chess[turn] && row >= MIN){
  20.                 count_N++;
  21.         }
  22.         return count_N;
  23. }
  24. int judge_S(int row,int col,int turn){
  25.         int count_S = 0;
  26.         while(chessBoard[row++][col] == chess[turn] && row <= MAX){
  27.                 count_S++;
  28.         }
  29.         return count_S;
  30. }
  31. int judge_E(int row,int col,int turn){
  32.         int count_E = 0;
  33.         while(chessBoard[row][col++] == chess[turn] && col <= MAX){
  34.                 count_E++;
  35.         }
  36.         return count_E;
  37. }
  38. int judge_W(int row,int col,int turn){
  39.         int count_W = 0;
  40.         while(chessBoard[row][col--] == chess[turn] && col >= MIN){
  41.                 count_W++;
  42.         }
  43.         return count_W;
  44. }
  45. int judge_NW(int row,int col,int turn){
  46.         int count_NW = 0;
  47.         while(chessBoard[row++][col--] == chess[turn] && (row <= MAX && col >= MIN)){
  48.                 count_NW++;
  49.         }
  50.         return count_NW;
  51. }
  52. int judge_NE(int row,int col,int turn){
  53.         int count_NE = 0;
  54.         while(chessBoard[row++][col++] == chess[turn] && (row <= MAX && col <= MAX)){
  55.                 count_NE++;
  56.         }
  57.         return count_NE;
  58. }
  59. int judge_SE(int row,int col,int turn){
  60.         int count_SE = 0;
  61.         while(chessBoard[row--][col++] == chess[turn] && (row >= MIN && col <= MAX)){
  62.                 count_SE++;
  63.         }
  64.         return count_SE;
  65. }
  66. int judge_SW(int row,int col,int turn){
  67.         int count_SW = 0;
  68.         while(chessBoard[row--][col--] == chess[turn] && (row >= MIN && col >= MIN)){
  69.                 count_SW++;
  70.         }
  71.         return count_SW;
  72. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-30 14:51:48 | 显示全部楼层
人造人 发表于 2019-1-30 13:15
我知道问题了,你在判断的时候多加了一次

能在注释里告诉我哪里多判断了一次么,我代码太乱了
我也不知道是哪里的判断多了一次
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-1-30 15:17:41 | 显示全部楼层
cookies945 发表于 2019-1-30 14:51
能在注释里告诉我哪里多判断了一次么,我代码太乱了
我也不知道是哪里的判断多了一次
{:10_2 ...
  1. int judge_N(int row, int col, int turn){
  2.         int count_N = 0;
  3.         while(chessBoard[row--][col] == chess[turn] && row >= MIN){
  4.                 count_N++;
  5.         }
  6.         return count_N;
  7. }
  8. int judge_S(int row, int col, int turn){
  9.         int count_S = 0;
  10.         while(chessBoard[++row][col] == chess[turn] && row <= MAX){
  11.                 count_S++;
  12.         }
  13.         return count_S;
  14. }
复制代码





  1. int judge(int row, int col, int turn){
  2.         int N = 0, S = 0, E = 0, W = 0, NW = 0, NE = 0, SW = 0, SE = 0;
  3.         turn = turn % 2;
  4.         N = judge_N(row, col, turn);
  5.         S = judge_S(row, col, turn);
  6.         W = judge_W(row, col, turn);
  7.         E = judge_E(row, col, turn);
  8.         SW = judge_SW(row, col, turn);
  9.         SE = judge_SE(row, col, turn);
  10.         NW = judge_NW(row, col, turn);
  11.         NE = judge_NE(row, col, turn);
  12.         if(N + S >= 5 || W + E >= 5 || SW + NW >= 5 || NE + SE >= 5){
  13.                 return 1;
  14.         }
  15.         return 0;
  16. }
  17. int judge_N(int row, int col, int turn){
  18.         int count_N = 0;
  19.         while(chessBoard[row--][col] == chess[turn] && row >= MIN){
  20.                 count_N++;
  21.         }
  22.         return count_N;
  23. }
  24. int judge_S(int row, int col, int turn){
  25.         int count_S = 0;
  26.         while(chessBoard[++row][col] == chess[turn] && row <= MAX){
  27.                 count_S++;
  28.         }
  29.         return count_S;
  30. }
  31. int judge_E(int row, int col, int turn){
  32.         int count_E = 0;
  33.         while(chessBoard[row][col++] == chess[turn] && col <= MAX){
  34.                 count_E++;
  35.         }
  36.         return count_E;
  37. }
  38. int judge_W(int row, int col, int turn){
  39.         int count_W = 0;
  40.         while(chessBoard[row][--col] == chess[turn] && col >= MIN){
  41.                 count_W++;
  42.         }
  43.         return count_W;
  44. }
  45. int judge_NW(int row, int col, int turn){
  46.         int count_NW = 0;
  47.         while(chessBoard[row++][col--] == chess[turn] && (row <= MAX && col >= MIN)){
  48.                 count_NW++;
  49.         }
  50.         return count_NW;
  51. }
  52. int judge_NE(int row, int col, int turn){
  53.         int count_NE = 0;
  54.         while(chessBoard[++row][++col] == chess[turn] && (row <= MAX && col <= MAX)){
  55.                 count_NE++;
  56.         }
  57.         return count_NE;
  58. }
  59. int judge_SE(int row, int col, int turn){
  60.         int count_SE = 0;
  61.         while(chessBoard[row--][col++] == chess[turn] && (row >= MIN && col <= MAX)){
  62.                 count_SE++;
  63.         }
  64.         return count_SE;
  65. }
  66. int judge_SW(int row, int col, int turn){
  67.         int count_SW = 0;
  68.         while(chessBoard[--row][--col] == chess[turn] && (row >= MIN && col >= MIN)){
  69.                 count_SW++;
  70.         }
  71.         return count_SW;
  72. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-1-30 15:18:29 | 显示全部楼层
while(chessBoard[row--][col] == chess[turn] && row >= MIN){
while(chessBoard[++row][col] == chess[turn] && row <= MAX){
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

发表于 2019-1-30 18:35:07 | 显示全部楼层
人造人 发表于 2019-1-30 15:18
while(chessBoard[row--][col] == chess[turn] && row >= MIN){
while(chessBoard[++row][col] == chess[t ...

算法了解的很到位,代码看得很仔细!
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-1-31 10:34:55 | 显示全部楼层
本帖最后由 cookies945 于 2019-1-31 11:01 编辑
人造人 发表于 2019-1-30 15:18
while(chessBoard[row--][col] == chess[turn] && row >= MIN){
while(chessBoard[++row][col] == chess[t ...


emm 还是有点小问题呀
斜着判断还是会出错
0   1   2   3   4   5   6   7   8   9  10  11  12  13
1   *   *   *   *   0   *   *   *   *   *   *   *   @
2   *   *   *   0   *   *   *   *   *   *   *   *   @
3   *   *   0   *   *   *   *   *   *   *   *   *   @
4   *   0   *   *   *   *   *   *   *   *   *   *   @
5   0   *   *   *   *   *   *   *   *   *   *   *   *
6   *   *   *   *   *   *   *   *   *   *   *   *   *
7   *   *   *   *   *   *   *   *   *   *   *   *   *
8   *   *   *   *   *   *   *   *   *   *   *   *   *
9   *   *   *   *   *   *   *   *   *   *   *   *   *
10   *   *   *   *   *   *   *   *   *   *   *   *   *
11   *   *   *   *   *   *   *   *   *   *   *   *   *
12   *   *   *   *   *   *   *   *   *   *   *   *   *
13   *   *   *   *   *   *   *   *   *   *   *   *   *
请黑棋落子!请输入要落子的坐标(行 列):
这里应该白棋获胜了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-1-31 15:57:23 | 显示全部楼层
cookies945 发表于 2019-1-31 10:34
emm 还是有点小问题呀
斜着判断还是会出错
0   1   2   3   4   5   6   7   8   9  10  11  12  13
...

是++ -- 运算符导致的
其他judge函数我没看,如果有问题,照着下面这样改

  1. int judge_NW(int row, int col, int turn){
  2.         int count_NW = 0;
  3.         /*while(chessBoard[row++][col--] == chess[turn] && (row <= MAX && col >= MIN)){
  4.                 count_NW++;
  5.         }*/
  6.         while(chessBoard[row][col] == chess[turn] && (row <= MAX && col >= MIN)){
  7.                 ++row;
  8.                 --col;
  9.                 count_NW++;
  10.         }
  11.         return count_NW;
  12. }
  13. int judge_NE(int row, int col, int turn){
  14.         int count_NE = 0;
  15.         /*while(chessBoard[++row][++col] == chess[turn] && (row <= MAX && col <= MAX)){
  16.                 count_NE++;
  17.         }*/

  18.         ++row;
  19.         ++col;
  20.         while(chessBoard[row][col] == chess[turn] && (row <= MAX && col <= MAX)){
  21.                 ++row;
  22.                 ++col;
  23.                 count_NE++;
  24.         }
  25.         return count_NE;
  26. }
  27. int judge_SE(int row, int col, int turn){
  28.         int count_SE = 0;
  29.         /*while(chessBoard[row--][col++] == chess[turn] && (row >= MIN && col <= MAX)){
  30.                 count_SE++;
  31.         }*/

  32.         while(chessBoard[row][col] == chess[turn] && (row >= MIN && col <= MAX)){
  33.                 --row;
  34.                 ++col;
  35.                 count_SE++;
  36.         }
  37.         return count_SE;
  38. }
  39. int judge_SW(int row, int col, int turn){
  40.         int count_SW = 0;
  41.         /*while(chessBoard[--row][--col] == chess[turn] && (row >= MIN && col >= MIN)){
  42.                 count_SW++;
  43.         }*/

  44.         --row;
  45.         --col;
  46.         while(chessBoard[row][col] == chess[turn] && (row >= MIN && col >= MIN)){
  47.                 --row;
  48.                 --col;
  49.                 count_SW++;
  50.         }
  51.         return count_SW;
  52. }
复制代码



  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>

  4. #define MAX 13
  5. #define MIN 1

  6. int addBlack(int row_in_fun, int col_in_fun, int count);
  7. int addWhite(int row_in_fun, int col_in_fun, int count);
  8. void cleanChessBoard(char* CB, int n);
  9. int judge(int row_in_fun, int col_in_fun, int trun);
  10. void printChessBoard(void);
  11. void choose(void);
  12. int judge_N(int row, int col, int turn);
  13. int judge_S(int row, int col, int turn);
  14. int judge_E(int row, int col, int turn);
  15. int judge_W(int row, int col, int turn);
  16. int judge_NW(int row, int col, int turn);
  17. int judge_NE(int row, int col, int turn);
  18. int judge_SE(int row, int col, int turn);
  19. int judge_SW(int row, int col, int turn);

  20. char chessBoard[14][14];
  21. char chess[2] = {'0', '@'};

  22. int main(){
  23.         //char tmp[14][14] = {
  24.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  25.         //        {0, 0, '@', '0', '@', '@', '@', '@', '0', 0, 0, 0, 0, 0},
  26.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  27.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  28.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  29.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  30.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  31.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  32.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  33.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  34.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  35.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  36.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  37.         //        {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  38.         //};
  39.         //
  40.         //memcpy(chessBoard, tmp, sizeof(tmp));
  41.         //printf("%d\n", judge(1, 2, 1));
  42.         //exit(1);


  43.         char *CB;
  44.         CB = &chessBoard[0][0];
  45.         cleanChessBoard(CB, 14);
  46.         choose();
  47.         return 0;
  48. }
  49. void cleanChessBoard(char* CB, int n){
  50.         int i, j;
  51.         for(i = 0; i < n; i++){  // n 为行
  52.                 for(j = 0; j < n; j++){ // j 为列

  53.                         if(i == 0){
  54.                                 printf("%2d", j); // 第一行打印棋盘上面的数字坐标

  55.                         }
  56.                         else if(j == 0 && i != 0){ //每一行的开头打印列标
  57.                                 printf("%2d", i);
  58.                         }
  59.                         else{
  60.                                 printf(" ");
  61.                                 *(CB + i * n + j) = '*';       //未落子的区域打印 * 表明未落子;
  62.                                 printf("%c", chessBoard[i][j]);
  63.                         } // 打印棋盘
  64.                         printf("  ");
  65.                 }
  66.                 printf("\n");
  67.         }
  68. }
  69. int addBlack(int row_in_fun, int col_in_fun, int count){
  70.         int flag;//接收judge的返回值,判断是否结束比赛
  71.         if(chessBoard[row_in_fun][col_in_fun] == '*'){   //判断该区域是否已经落了子
  72.                 chessBoard[row_in_fun][col_in_fun] = '@';
  73.                 flag = judge(row_in_fun, col_in_fun, count);
  74.                 if(flag){
  75.                         printf("黑棋获胜!\n");
  76.                         return 1;
  77.                 }
  78.         }
  79.         else{
  80.                 printf("这里有棋子了!");
  81.                 printf("重新输入坐标:");
  82.                 int row, col;
  83.                 scanf("%d %d", &row, &col);
  84.                 addBlack(row, col, count);
  85.         }
  86.         return 0;
  87. }
  88. int addWhite(int row_in_fun, int col_in_fun, int count){
  89.         int flag;//接收judge的返回值,判断是否结束比赛
  90.         if(chessBoard[row_in_fun][col_in_fun] == '*'){
  91.                 chessBoard[row_in_fun][col_in_fun] = '0';
  92.                 flag = judge(row_in_fun, col_in_fun, count);
  93.                 if(flag){
  94.                         printf("白棋获胜!\n");
  95.                         return 1;
  96.                 }
  97.         }
  98.         else{
  99.                 printf("这里有棋子了!");
  100.                 printf("重新输入坐标:");
  101.                 int row, col;
  102.                 scanf("%d %d", &row, &col);
  103.                 addWhite(row, col, count);
  104.         }
  105.         return 0;
  106. }
  107. void printChessBoard(void){
  108.         int i, j;
  109.         for(i = 0; i < 14; i++){  // n 为行
  110.                 for(j = 0; j < 14; j++){ // j 为列

  111.                         if(i == 0){
  112.                                 printf("%2d", j); // 第一行打印棋盘上面的数字坐标

  113.                         }
  114.                         else if(j == 0 && i != 0){ //每一行的开头打印列标
  115.                                 printf("%2d", i);
  116.                         }
  117.                         else{
  118.                                 printf(" ");
  119.                                 printf("%c", chessBoard[i][j]);
  120.                         } // 打印棋盘
  121.                         printf("  ");
  122.                 }
  123.                 printf("\n");
  124.         }
  125. }
  126. void choose(void){
  127.         int count = 0;//判断是谁下棋
  128.         int row, col;
  129.         int end;//结束判断
  130.         do{
  131.                 if(count % 2 == 0){
  132.                         printf("请白棋落子!");
  133.                 }
  134.                 else{
  135.                         printf("请黑棋落子!");
  136.                 }
  137.                 printf("请输入要落子的坐标(行 列):");
  138.                 scanf("%d %d", &row, &col);
  139.                 if(count % 2 == 0){
  140.                         end = addWhite(row, col, count);
  141.                         count++;
  142.                 }
  143.                 else{
  144.                         end = addBlack(row, col, count);
  145.                         count++;
  146.                 }
  147.                 printChessBoard();
  148.                 if(end){
  149.                         break;
  150.                 }
  151.         }
  152.         while(1);
  153. }

  154. int judge(int row, int col, int turn){
  155.         int N = 0, S = 0, E = 0, W = 0, NW = 0, NE = 0, SW = 0, SE = 0;
  156.         turn = turn % 2;
  157.         N = judge_N(row, col, turn);
  158.         S = judge_S(row, col, turn);
  159.         W = judge_W(row, col, turn);
  160.         E = judge_E(row, col, turn);
  161.         SW = judge_SW(row, col, turn);
  162.         SE = judge_SE(row, col, turn);
  163.         NW = judge_NW(row, col, turn);
  164.         NE = judge_NE(row, col, turn);
  165.         if(N + S >= 5 || W + E >= 5 || SW + NW >= 5 || NE + SE >= 5){
  166.                 return 1;
  167.         }
  168.         return 0;
  169. }
  170. int judge_N(int row, int col, int turn){
  171.         int count_N = 0;
  172.         while(chessBoard[row--][col] == chess[turn] && row >= MIN){
  173.                 count_N++;
  174.         }
  175.         return count_N;
  176. }
  177. int judge_S(int row, int col, int turn){
  178.         int count_S = 0;
  179.         while(chessBoard[++row][col] == chess[turn] && row <= MAX){
  180.                 count_S++;
  181.         }
  182.         return count_S;
  183. }
  184. int judge_E(int row, int col, int turn){
  185.         int count_E = 0;
  186.         while(chessBoard[row][col++] == chess[turn] && col <= MAX){
  187.                 count_E++;
  188.         }
  189.         return count_E;
  190. }
  191. int judge_W(int row, int col, int turn){
  192.         int count_W = 0;
  193.         while(chessBoard[row][--col] == chess[turn] && col >= MIN){
  194.                 count_W++;
  195.         }
  196.         return count_W;
  197. }
  198. int judge_NW(int row, int col, int turn){
  199.         int count_NW = 0;
  200.         /*while(chessBoard[row++][col--] == chess[turn] && (row <= MAX && col >= MIN)){
  201.                 count_NW++;
  202.         }*/
  203.         while(chessBoard[row][col] == chess[turn] && (row <= MAX && col >= MIN)){
  204.                 ++row;
  205.                 --col;
  206.                 count_NW++;
  207.         }
  208.         return count_NW;
  209. }
  210. int judge_NE(int row, int col, int turn){
  211.         int count_NE = 0;
  212.         /*while(chessBoard[++row][++col] == chess[turn] && (row <= MAX && col <= MAX)){
  213.                 count_NE++;
  214.         }*/

  215.         ++row;
  216.         ++col;
  217.         while(chessBoard[row][col] == chess[turn] && (row <= MAX && col <= MAX)){
  218.                 ++row;
  219.                 ++col;
  220.                 count_NE++;
  221.         }
  222.         return count_NE;
  223. }
  224. int judge_SE(int row, int col, int turn){
  225.         int count_SE = 0;
  226.         /*while(chessBoard[row--][col++] == chess[turn] && (row >= MIN && col <= MAX)){
  227.                 count_SE++;
  228.         }*/

  229.         while(chessBoard[row][col] == chess[turn] && (row >= MIN && col <= MAX)){
  230.                 --row;
  231.                 ++col;
  232.                 count_SE++;
  233.         }
  234.         return count_SE;
  235. }
  236. int judge_SW(int row, int col, int turn){
  237.         int count_SW = 0;
  238.         /*while(chessBoard[--row][--col] == chess[turn] && (row >= MIN && col >= MIN)){
  239.                 count_SW++;
  240.         }*/

  241.         --row;
  242.         --col;
  243.         while(chessBoard[row][col] == chess[turn] && (row >= MIN && col >= MIN)){
  244.                 --row;
  245.                 --col;
  246.                 count_SW++;
  247.         }
  248.         return count_SW;
  249. }
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-1-31 16:00:17 | 显示全部楼层
还有,要学会调试,这样的问题只是用眼睛盯着代码看是看不出来的,当然有那么一些高手例外,既然你我都不是高手,那就乖乖调试吧

小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2019-1-31 16:32:13 | 显示全部楼层
都是大佬!小弟膜拜
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2019-2-2 19:30:11 | 显示全部楼层
人造人 发表于 2019-1-31 16:00
还有,要学会调试,这样的问题只是用眼睛盯着代码看是看不出来的,当然有那么一些高手例外,既然你我都不是 ...

嗯受教了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-7-4 14:57

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表