c语言五子棋游戏代码详细解释,C语言案例:控制台版本的五子棋游戏【代码】...

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

return true;

}

x++;

}

return false;

}

bool isLeftInclinedWin(bool isBlack,int x,int y)

{

char c = isBlack ? '@':'O';

int count;

while(x>0 && y>0 && state[x][y] == c)

{

y--;

x--;

}

count =0;

if(state[x][y] == c) count = 1;

x++;

y++;

while(x < N && y < N && state[x][y] == c)

{

count++;

if(count == 5)

{

return true;

}

x++;

y++;

}

return false;

}

bool isRightObliqueWin(bool isBlack,int x,int y)

{

char c = isBlack ? '@':'O';

int count;

while(x>0 && y

{

y++;

x--;

}

count =0;

if(state[x][y] == c) count = 1;

x++;

y--;

while(x < N && y >= 0 && state[x][y] == c)

{

count++;

if(count == 5)

{

return true;

}

x++;

y--;

}

return false;

}

void init(void)

{

int i,j;

for(i=0;i

{

for(j=0;j

{

state[i][j] = '*';

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
一个很好的五子棋c语言源程序代码,最重要的是能运行正确!!! #include #include #include #include #include #define CROSSRU 0xbf /*右上角点*/ #define CROSSLU 0xda /*左上角点*/ #define CROSSLD 0xc0 /*左下角点*/ #define CROSSRD 0xd9 /*右下角点*/ #define CROSSL 0xc3 /*左边*/ #define CROSSR 0xb4 /*右边*/ #define CROSSU 0xc2 /*上边*/ #define CROSSD 0xc1 /*下边*/ #define CROSS 0xc5 /*十字交叉点*/ /*定义棋盘左上角点在屏幕上的位置*/ #define MAPXOFT 5 #define MAPYOFT 2 /*定义1号玩家的操作键键码*/ #define PLAY1UP 0x1157/*上移--'W'*/ #define PLAY1DOWN 0x1f53/*下移--'S'*/ #define PLAY1LEFT 0x1e41/*左移--'A'*/ #define PLAY1RIGHT 0x2044/*右移--'D'*/ #define PLAY1DO 0x3920/*落子--空格键*/ /*定义2号玩家的操作键键码*/ #define PLAY2UP 0x4800/*上移--方向键up*/ #define PLAY2DOWN 0x5000/*下移--方向键down*/ #define PLAY2LEFT 0x4b00/*左移--方向键left*/ #define PLAY2RIGHT 0x4d00/*右移--方向键right*/ #define PLAY2DO 0x1c0d/*落子--回车键Enter*/ /*若想在游戏中途退出, 可按 Esc 键*/ #define ESCAPE 0x011b /*定义棋盘上交叉点的状态, 即该点有无棋子 */ /*若有棋子, 还应能指出是哪个玩家的棋子 */ #define CHESSNULL 0 /*没有棋子*/ #define CHESS1 'O'/*一号玩家的棋子*/ #define CHESS2 'X'/*二号玩家的棋子*/ /*定义按键类别*/ #define KEYEXIT 0/*退出键*/ #define KEYFALLCHESS 1/*落子键*/ #define KEYMOVECURSOR 2/*光标移动键*/ #define KEYINVALID 3/*无效键*/ 下载可看到完整的...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值