91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 14KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-28
  • 語言: C/C++
  • 標簽: xiaopeng??

資源簡介

Linux下c語言編寫的五子棋,可在終端上運行,通過wads加回車可以控制光標的位置,空格鍵加回車可以在當前位置下棋。實現局域網內的client/server游戲對戰。

資源截圖

代碼片段和文件信息

/****************************************
?*?@File?name:?client.c
?*?@Author:?xiaopeng
?*?@Version:?1.1
?*?@Date:?2018-8-23
?*?Description:?A?game?of?chess
?****************************************/

#include?“chess.h“

//flush?chess
void?print_map(int?(*a)[N])
{
int?ij;
for(i=0;?i {
for(j=0;?j {
switch(a[i][j])
{
case?0:?printf(“.?“);?break;??//?0?表示棋盤
case?1:?printf(“|?“);?break;??//?1?表示光標
case?2:?printf(“o?“);?break;??//?2?表示黑棋
case?3:?printf(“●?“);?break;??//?3?表示白棋
case?4:?printf(“①?“);?break;??//?4?表示光標在白棋上面
case?5:?printf(“②?“);?break;??//?5?表示光標在黑棋上面
}
}
printf(“\n“);
}
}

//deal?key
int?deal_key(int?(*a)[N]int?*xint?*yint?*flag)
{
char?get_ch?=?getchar();
switch(get_ch)
{
case?‘w‘:
{
if(*x?>?0)?(*x)?=?(*x)-1; ??//光標向上移動
if(a[*x][*y]?==?0)?a[*x][*y]?=?1;?????//空白處光標為1?
if(a[*x][*y]?==?2)?a[*x][*y]?=?4; ??//白棋上光標為4
if(a[*x][*y]?==?3)?a[*x][*y]?=?5;?????//黑棋上光標為5

if(a[*x+1][*y]?==?1)?a[*x+1][*y]?=?0;?//消除腳印
if(a[*x+1][*y]?==?4)?a[*x+1][*y]?=?2;?//消除腳印
if(a[*x+1][*y]?==?5)?a[*x+1][*y]?=?3;?//消除腳印
}break;

case?‘s‘:
{
if(*x? if(a[*x][*y]?==?0)?a[*x][*y]?=?1;?????//空白處光標為1?
if(a[*x][*y]?==?2)?a[*x][*y]?=?4; ??//白棋上光標為4
if(a[*x][*y]?==?3)?a[*x][*y]?=?5;?????//黑棋上光標為5

if(a[*x-1][*y]?==?1)?a[*x-1][*y]?=?0;
if(a[*x-1][*y]?==?4)?a[*x-1][*y]?=?2;
if(a[*x-1][*y]?==?5)?a[*x-1][*y]?=?3;
}break;

case?‘a‘:
{
if(*y?>?0)?(*y)?=?(*y)-1;
if(a[*x][*y]?==?0)?a[*x][*y]?=?1;?????//空白處光標為1?
if(a[*x][*y]?==?2)?a[*x][*y]?=?4; ??//白棋上光標為4
if(a[*x][*y]?==?3)?a[*x][*y]?=?5;?????//黑棋上光標為5

if(a[*x][*y+1]?==?1)?a[*x][*y+1]?=?0;
if(a[*x][*y+1]?==?4)?a[*x][*y+1]?=?2;
if(a[*x][*y+1]?==?5)?a[*x][*y+1]?=?3;
}break;
case?‘d‘:
{
if(*y? if(a[*x][*y]?==?0)?a[*x][*y]?=?1;?????//空白處光標為1?
if(a[*x][*y]?==?2)?a[*x][*y]?=?4; ??//白棋上光標為4
if(a[*x][*y]?==?3)?a[*x][*y]?=?5;?????//黑棋上光標為5

if(a[*x][*y-1]?==?1)?a[*x][*y-1]?=?0;
if(a[*x][*y-1]?==?4)?a[*x][*y-1]?=?2;
if(a[*x][*y-1]?==?5)?a[*x][*y-1]?=?3;
}break;

case?32:???
{
if(a[*x][*y]?==?1)
{
if((*flag)?==?1)?
a[*x][*y]?=?2;
else?a[*x][*y]?=?3;
*flag?=?!(*flag);
}
}break;
}
return?0;
}

//judge?victory
int?judge_victory(int?(*a)[N]int?*xint?*yint?*flag)
{
int?i?=?0j?=?0;
int?temp?=?(3-!(*flag));
for(i=0j=*y;?i {
if(temp==a[i][j]&&temp==a[i+1][j]&&temp==a[i+2][j]&&temp==a[i+3][j]&&temp==a[i+4][j])??//五子連珠
return?1;?
}
for(i=*xj=0;?j {
if(temp==a[i][j]&&temp==a[i][j+1]&&temp==a[i][j?+?2]&&temp==a[i][j+3]&&temp==a[i][j+4])
return?1;
}
//找到左下最后一個元素的行標掃描落子所在正對角線
for(i=(*x)+(*y)j=0;?i>=0;?i--j++)
{
if(temp==a[i][j]&&temp==a[i-1][j+1]&&temp==a[i-2][j+2]&&temp==a[i-3][j+3]&&temp==a[i-4][j+4])
return?1;
}
//先找到左上第一個元素的列標,掃描落子所在副對角線上
for(i=(*x)-(*y)j=0;?j {
if(temp==a[i][j]&&temp==a[i+1][j

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

????..A..H.?????12288??2018-08-24?12:02??chess\client\.跟我一起學Makefile.swp

?????文件???????3521??2018-09-07?15:27??chess\client\chess.c

?????文件????????234??2018-08-29?14:05??chess\client\chess.h

?????文件???????6616??2018-09-07?18:07??chess\client\chess.o

?????文件????????578??2018-09-07?15:57??chess\client\client.c

?????文件????????304??2018-09-07?16:06??chess\client\client.h

?????文件???????2160??2018-09-07?18:07??chess\client\client.o

?????文件????????137??2018-08-24?17:53??chess\client\define.h

?????文件???????1768??2018-09-07?16:37??chess\client\main.c

?????文件???????4008??2018-09-07?18:07??chess\client\main.o

?????文件????????184??2018-09-07?15:39??chess\client\makefile

?????文件???????3526??2018-09-07?16:01??chess\server\chess.c

?????文件????????235??2018-09-07?16:02??chess\server\chess.h

?????文件???????6616??2018-09-07?18:07??chess\server\chess.o

?????文件????????137??2018-08-24?17:51??chess\server\define.h

?????文件???????1582??2018-09-07?16:37??chess\server\main.c

?????文件???????3904??2018-09-07?18:07??chess\server\main.o

?????文件????????184??2018-09-07?15:53??chess\server\makefile

?????文件????????752??2018-09-07?16:04??chess\server\server.c

?????文件????????335??2018-09-07?16:07??chess\server\server.h

?????文件???????2312??2018-09-07?18:07??chess\server\server.o

?????目錄??????????0??2018-09-09?13:30??chess\client

?????目錄??????????0??2018-09-09?13:30??chess\server

?????目錄??????????0??2018-09-09?13:30??chess

-----------?---------??----------?-----??----

????????????????51381????????????????????24


評論

共有 條評論

相關資源