C語言編寫簡單的五子棋小遊戲

2021-10-25 02:20:26 字數 753 閱讀 5778

需要的資料:

1、定義乙個15*15的棋盤

2、定義變數用於記錄棋子的座標

3、定義角色變數

業務邏輯:

是否需要對資料進行初始化

for( ; ; )

5、宣布平局,結束遊戲

#include #include #include #include // 定義棋盤

char board[15][15];

// 棋子座標

char key_x = 7,key_y = 7;

// 角色

char role = '@';

// 初始化棋盤

void init_board(void) }}

// 顯示棋盤

void show_board(void)

printf("\n"); }}

// 落子

void get_key(void)

} }}

//計算乙個方向上有多少個相同的棋子

int count_key(int go_x,int go_y)//0 -1

else

}return count;

}// 檢查五子連珠

bool check_key(void)

int main(int argc,const char* ar**)

// 交換角色

role = role == '@'?'$':'@';

}}

c 小遊戲 五子棋

include include includeusing namespace std const int x 21 棋盤行數 const int y 21 棋盤列數 char p x y 定義棋盤 int m 0 定義臨時點,儲存輸入座標 int n 0 void display 輸出棋盤 else...

c 小遊戲 五子棋

include include includeusing namespace std const int x 21 棋盤行數 const int y 21 棋盤列數 char p x y 定義棋盤 int m 0 定義臨時點,儲存輸入座標 int n 0 void display 輸出棋盤 else...

簡單的五子棋小遊戲

chess類 public class chess public intgetxpos public void setxpos int xpos public intgetypos public void setypos int ypos public string getchesstype pub...