当前位置:首页 > 代码 > 正文

中国象棋c源代码(象棋软件源代码)

admin 发布:2022-12-19 23:47 132


本篇文章给大家谈谈中国象棋c源代码,以及象棋软件源代码对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

c语言代码输出国际象棋棋盘问题

%C是代表两个字符

219是一个占位符实际的数据插入一个占位符,对应

输出219字符插入序列,这里是ASCII码219;之间的整形和字符转换,字符为整数编译器分配给整型变量的ASCII字符代码;整数整数到字符转换为对应于分配给字符变量的字符的ASCII码表;

c++程序设计 中国象棋源代码

我提供两个功能完善,而且最重要的,我认为算法设计比较好的中国象棋源代码,因为是源码网的,所以可以学习参考下:

急需用c语言写中国象棋的代码,只要红色方布局和走棋

接上面中国象棋代码:

if( check_turn == 12)    //相的走法规范

       { if((x == check_x y == check_y))

            {temp = turn;  temp1 = turn1;  turn = 'O';  turn1 = 'N';  num--;

              printf("三思而后行\n"); printf("还是你的回合"); Sleep(500);

             }

         else if( x = 15 (abs(y - check_y) == 8 abs(x - check_x) == 4))

             {if((x == 22 (y == 11 || y == 27))||(x == 18

                ( y == 3 || y == 19 || y == 35)) ||(x == 14 (y == 11|| y ==27)))

                    { if( map[(x+check_x)/2][(y+check_y)/2] == '+')                                                  check_main1(temp,temp1,turn,turn1,num,if_return,map);

                      else {printf("棋子卡住,不可执行"); Sleep(500); }  }

                     else {printf("不合法的下法\n");Sleep(500); }

                  }

                else {printf("不合法的下法\n"); Sleep(500); }

              }

       if( check_turn == 13)    //士的走法规范

          { if((x == check_x y == check_y))

              {temp = turn;  temp1 = turn1;  turn = 'O';  turn1 = 'N';  num--;

               printf("三思而后行\n"); printf("还是你的回合"); Sleep(500);  }

    else if( abs(x - check_x)== 2 abs( y - check_y) == 4 ((x==22 (y == 15

        || y == 23)) || ( x == 20 y == 19) || ( x == 18 ( y == 15 || y == 23))))                      {check_main1(temp,temp1,turn,turn1,num,if_return,map); }

     else { printf("不合法的下法\n"); Sleep(500); }   }

     if( check_turn == 14)    //将的走法规范

         { if((x == check_x y == check_y))

              { temp = turn;  temp1 = turn1;  turn = 'O';  turn1 = 'N';  num--;

                 printf("三思而后行\n"); printf("还是你的回合"); Sleep(500);  }

else if( ((abs(x - check_x)== 2 abs( y - check_y) == 0 )|| (abs(x - check_x)== 0

  abs( y - check_y) == 4)) x = 18 x = 22 y = 15 y = 23 )

        { check_main1(temp,temp1,turn,turn1,num,if_return,map); }

           else { printf("不合法的下法\n"); Sleep(500); }   }

if( check_turn == 15)       //炮的走法规范

     { if((x == check_x y == check_y))

        {  temp = turn;  temp1 = turn1;  turn = 'O';  turn1 = 'N';  num--;

           printf("三思而后行\n"); printf("还是你的回合"); Sleep(500);  }

       else if( y == check_y )

            { int check_pao = 0;

              if( x check_x)

                 { for(j = check_x + 2; j= x ;j = j+ 2)

                    { if(map[j][y] == '+' );  else  check_pao++;}

                  if(check_pao == 1 temp == '+')   // 直线行走但不可吃棋子                                 check_main1(temp,temp1,turn,turn1,num,if_return,map);

                else if( check_pao == 2 temp != '+')  //跳跃吃棋                                                 check_main1(temp,temp1,turn,turn1,num,if_return,map);

               else { printf("不合法的下法\n"); Sleep(500); }  }

            else { for(j = check_x - 2; j= x;j = j - 2)

             { if(map[j][y] == '+' );  else { check_pao++;} }

                if(check_pao == 1 temp == '+')   //直线行走但不可吃棋子                                  check_main1(temp,temp1,turn,turn1,num,if_return,map);

                 else if( check_pao == 2 temp != '+')   //跳跃吃棋                                            check_main1(temp,temp1,turn,turn1,num,if_return,map);

              else { printf("不合法的下法\n"); Sleep(500); }  }

             }

           else if( x == check_x )

             { int check_pao = 0;

                if( y check_y)

                   { for(j = check_y + 4; j= y ;j = j+4)

                      { if(map[x][j] == '+' );  else    check_pao++;}

                   if(check_pao == 1 temp == '+')  //直线行走但不可吃棋子                                   check_main1(temp,temp1,turn,turn1,num,if_return,map);

                 else if( check_pao == 2 temp != '+')   //跳跃吃棋                                                 check_main1(temp,temp1,turn,turn1,num,if_return,map);

                 else { printf("不合法的下法\n"); Sleep(500); }  }

              else {for(j = check_y - 4; j= y;j = j - 4)

                  {if(map[x][j] == '+' );  else  check_pao++;}

                     if(check_pao == 1 temp == '+')  //直线行走但不可吃棋子                                  check_main1(temp,temp1,turn,turn1,num,if_return,map);

               else if( check_pao == 2 temp != '+')   //跳跃吃棋                                                    check_main1(temp,temp1,turn,turn1,num,if_return,map);

               else { printf("不合法的下法\n"); Sleep(500); }  }

            }

          else { printf("不合法的下法\n");Sleep(500); }

         }

       if( check_turn == 16)    //卒的走法规范

          { if ( x = 14)

          { if((x == check_x y == check_y))

              {  temp = turn;  temp1 = turn1;  turn = 'O';  turn1 = 'N';  num--;

                 printf("三思而后行\n"); printf("还是你的回合");  Sleep(500);  }

    else if( x == check_x - 2 y == check_y)                                                     check_main1(temp,temp1,turn,turn1,num,if_return,map);

  else { printf("不合法的下法\n"); Sleep(500); }

}

else{ if((x == check_x y == check_y))

  {  temp = turn;  temp1 = turn1;  turn = 'O';  turn1 = 'N';  num--;

    printf("三思而后行\n"); printf("还是你的回合"); Sleep(500);  }

else if((x - check_x == 0 abs(y-check_y) ==4) ||( x - check_x == -2

        abs(y-check_y) == 0))                                           check_main1(temp,temp1,turn,turn1,num,if_return,map);

else { printf("不合法的下法\n"); Sleep(500); }   }

  }

}

else  { if( check_turn == 20)  //车的走法规范 (帅方)

  { if((x == check_x y == check_y))

     {  temp = turn;  temp1 = turn1; turn = 'O'; turn1 = 'N';  num--;

        printf("三思而后行\n"); printf("还是你的回合"); Sleep(500);  }

else if( y == check_y )

     { if( x check_x)

       { for(j = check_x + 2; j x;j = j + 2)

         { if(map[j][y] == '+'); else {printf("不合法的下法\n"); Sleep(500); break; } }

  if( j = x) check_main2(temp,temp1,turn,turn1,num,if_return,map);

  }

if( x check_x)

    { for(j = check_x - 2; j x;j = j - 2)

       { if(map[j][y] == '+'); else { printf("不合法的下法\n"); Sleep(500); break; } }

if( j = x) check_main2(temp,temp1,turn,turn1,num,if_return,map);

}

}

else if(  x == check_x  )

   { if( y check_y)

     { for(j = check_y + 4; j y;j = j + 4)

      { if(map[x][j] == '+'); else { printf("不合法的下法\n"); Sleep(500); break; } }

   if( j = y) check_main2(temp,temp1,turn,turn1,num,if_return,map);

  }

if( y check_y)

   { for(j = check_y - 4; j y;j = j - 4)

     { if(map[x][j] == '+'); else { printf("不合法的下法\n");Sleep(500); break; } }

if( j = y) check_main2(temp,temp1,turn,turn1,num,if_return,map);

  }

}

else { printf("不合法的下法\n"); Sleep(500); }

}

if( check_turn == 21)    //马的走法规范

   { if((x == check_x y == check_y))

     { temp = turn; temp1 = turn1; turn = 'O'; turn1 = 'N'; num--;

        printf("三思而后行\n");printf("还是你的回合"); Sleep(500); }

  else if( (abs( x - check_x) == 2 abs( y - check_y) == 8)

        map[check_x][(y+check_y)/2] =='+')

      { check_main2(temp,temp1,turn,turn1,num,if_return,map); }

else if( (abs( x - check_x) == 4 abs( y - check_y) == 4)

      map[(x + check_x)/2][check_y] == '+' )

   { check_main2(temp,temp1,turn,turn1,num,if_return,map); }

else { printf("不合法的下法\n");Sleep(500); }  }

  if( check_turn == 22)    //相的走法规范

   { if((x == check_x y == check_y))

      { temp = turn; temp1 = turn1; turn = 'O'; turn1 = 'N'; num--;

         printf("三思而后行\n");printf("还是你的回合"); Sleep(500); }

     else if( x = 12 (abs(y - check_y) == 8 abs(x - check_x) == 4))

     { if((x == 4 (y == 11 || y == 27))||(x == 8 ( y == 3 || y == 19 || y == 35))

       ||(x == 12 (y == 11|| y ==27)))

       {  if( map[(x+check_x)/2][(y+check_y)/2] == '+')                                                   check_main2(temp,temp1,turn,turn1,num,if_return,map);

   else { printf("棋子卡住,不可执行");Sleep(500); }  }

else {printf("不合法的下法\n");Sleep(500); }

}

else { printf("不合法的下法\n");Sleep(500); }  }

if( check_turn == 23)    //士的走法规范

  { if((x == check_x y == check_y))

     { temp = turn; temp1 = turn1; turn = 'O'; turn1 = 'N'; num--;

         printf("三思而后行\n");printf("还是你的回合"); Sleep(500);  }

   else if( abs(x - check_x)== 2 abs( y - check_y) == 4 ((x==4

(y == 15 || y == 23)) || ( x == 6 y == 19) || ( x == 8 ( y == 15 || y == 23))))

     { check_main2(temp,temp1,turn,turn1,num,if_return,map); }

     else { printf("不合法的下法\n");Sleep(500); }  }

  if( check_turn == 24)    //将的走法规范

   { if((x == check_x y == check_y))

      { temp = turn; temp1 = turn1; turn = 'O'; turn1 = 'N'; num--;

         printf("三思而后行\n");printf("还是你的回合"); Sleep(500);  }

   else if( ((abs(x - check_x)== 2 abs( y - check_y) == 0 )|| (abs(x - check_x)== 0   abs( y - check_y) == 4)) x = 4 x = 8 y = 15 y = 23 )

   { check_main2(temp,temp1,turn,turn1,num,if_return,map); }

  else {printf("不合法的下法\n");Sleep(500); }  }

  if( check_turn == 25)    //炮的走法规范

     { if((x == check_x y == check_y))

         { temp = turn;  temp1 = turn1; turn = 'O'; turn1 = 'N'; num--;

             printf("三思而后行\n");printf("还是你的回合"); Sleep(500);  }

      else if( y == check_y )

          { int check_pao = 0;

            if( x check_x)

              { for(j = check_x + 2; j= x ;j = j+ 2)

                { if(map[j][y] == '+' );  else      check_pao++;}

                 if(check_pao == 1 temp == '+')   //直线行走但不可吃棋子                                 check_main2(temp,temp1,turn,turn1,num,if_return,map);

     else if( check_pao == 2 temp != '+')   //跳跃吃棋                                                       check_main2(temp,temp1,turn,turn1,num,if_return,map);

     else { printf("不合法的下法\n");Sleep(500); }  }

     else { for(j = check_x - 2; j= x;j = j - 2)

        { if(map[j][y] == '+' );  else { check_pao++;} }

            if(check_pao == 1 temp== '+')   //直线行走但不可吃棋子                                   check_main2(temp,temp1,turn,turn1,num,if_return,map);

       else if( check_pao == 2 temp != '+')   //跳跃吃棋                                                      check_main2(temp,temp1,turn,turn1,num,if_return,map);

    else { printf("不合法的下法\n");Sleep(500); }  }

  }

else if( x == check_x )

    { int check_pao = 0;

         if( y check_y)

            { for(j = check_y + 4; j= y ;j = j+4)

                { if(map[x][j] == '+' );  else check_pao++;}

           if(check_pao == 1 temp == '+')   //直线行走但不可吃棋                                              check_main2(temp,temp1,turn,turn1,num,if_return,map);

         else if( check_pao == 2 temp != '+')   //跳跃吃棋                                                 check_main2(temp,temp1,turn,turn1,num,if_return,map);

         else { printf("不合法的下法\n");Sleep(500); }  }

     else { for(j = check_y - 4 ; j= y;j = j - 4)

         { if(map[x][j] == '+' );  else  check_pao++;}

            if(check_pao ==1 temp == '+')   //直线行走但不可吃棋子                                     check_main2(temp,temp1,turn,turn1,num,if_return,map);

     else if( check_pao == 2 temp != '+')  //跳跃吃棋                                                       check_main2(temp,temp1,turn,turn1,num,if_return,map);

      else { printf("不合法的下法\n");Sleep(500); }  }

    }

  else { printf("不合法的下法\n");Sleep(500); }

   }

   if( check_turn == 26)  //卒的走法规范

      { if( x = 12)

        { if((x == check_x y == check_y))

          { temp = turn; temp1 = turn1; turn = 'O'; turn1 = 'N'; num--;

             printf("三思而后行\n"); printf("还是你的回合"); Sleep(500); }

    else if( x == check_x + 2 y == check_y)                                               check_main2(temp,temp1,turn,turn1,num,if_return,map);

  else { printf("不合法的下法\n");Sleep(500); }  }

  else{ if((x == check_x y == check_y))

     { temp = turn; temp1 = turn1; turn = 'O'; turn1 = 'N'; num--;

        printf("三思而后行\n");printf("还是你的回合"); Sleep(500);  }

  else if((x - check_x == 0 abs(y-check_y) ==4) ||( x - check_x == 2

      abs(y-check_y) == 0))                                                       check_main2(temp,temp1,turn,turn1,num,if_return,map);

else { printf("不合法的下法\n");Sleep(500); }   }

   }

  }

}

}

system("cls");

if( if_return) return;

for(i = 0; i 27; i++)puts(map[i]);

}

Sleep(5000);

}

int main( )

{ while(1)

    { xiangqi( );

      printf("\n  重来,请按键.\n");

      getch( );

    }

  return 0;

}

用C语言输出中国象棋棋盘的源代码!!急!急!急!

#include stdio.h

void main()

{int r=0;

int c=0;

int star_one=10;

for(r=0;r=star_one*9;r+=2)

{ for(c=0;c=star_one*8;c++)

{if((r%star_one==0 || c%star_one==0)c%2==0 (r=star_one*4 || r=star_one*4+star_one) || (r=star_one*4 r=star_one*4+star_one (c==0 || c==star_one*8)))

{printf("%c",'*');}

else

{printf("%c",' ');}

}

printf("\n");

}

}

关于中国象棋c源代码和象棋软件源代码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

版权说明:如非注明,本站文章均为 AH站长 原创,转载请注明出处和附带本文链接;

本文地址:http://ahzz.com.cn/post/30934.html


取消回复欢迎 发表评论:

分享到

温馨提示

下载成功了么?或者链接失效了?

联系我们反馈

立即下载