下面是一个简单的C语言五子棋实现示例:
- #include <stdio.h>
- #include <stdlib.h>
- #define BOARD_SIZE 15
- char board[BOARD_SIZE][BOARD_SIZE];
- void init_board() {
- int i, j;
- for (i = 0; i < BOARD_SIZE; i++) {
- for (j = 0; j < BOARD_SIZE; j++) {
- board[i][j] = '-';
- }
- }
- }
- void print_board() {
- int i, j;
- printf("\n");
- for (i = 0; i < BOARD_SIZE; i++) {
- for (j = 0; j < BOARD_SIZE; j++) {
- printf("%c ", board[i][j]);
- }
- printf("\n");
- }
- }
- int check_win() {
- int i, j, count;
- // check horizontal
- for (i = 0; i < BOARD_SIZE; i++) {
- for (j = 0; j < BOARD_SIZE - 4; j++) {
- if (board[i][