game.h
#ifndef __GAME_H__
#define __GAME_H__
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#define ROW 6
#define COL 6
void InitBoard(char board[ROW][COL], int row, int col);
void DisplayBoard(char board[ROW][COL], int row, int col);
void PlayerMove(char board[ROW][COL], int row, int col);
void Computermove(char board[ROW][COL], int row, int col);
char IsWin(char board[ROW][COL], int row, int col);
#endif //__GAME_H__
game.c
#define _CRT_SECURE_NO_WARNINGS
#include "game.h"
void InitBoard(char board[ROW][COL], int row, int col) //初始化棋盘
{
int i = 0;
int j = 0;
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
board[i][j] = ' ';
}
}
}
void DisplayBoard (char board[ROW][COL], int row, int col) //打印显示棋盘
{
/*int i=0;
for(i=0;i<row;i++)
{
printf(" %c | %c | %c \n",board[i][0],board[i][1],board[i][2]);
if(i<(row-1))
{
printf("---|---|---\n");
}
}*/
int i = 0;
for(i=0;i<row;i++)
{
int j = 0;
for(j=0;j<col;j++)
{
printf(" %c |",board[i][j]);
}
printf("\n");
for(j=0;j<col;j++)
{
if(i<(row-1))
{
printf("---|");
}
}
printf("\n");
}
}
void PlayerMove(char
三子棋(c语言) 棋盘大小可随意
最新推荐文章于 2022-02-10 22:03:18 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)