井字棋
井字棋,英文名叫Tic-Tac-Toe,是一种在3*3格子上进行的连珠游戏,和五子棋类似,由于棋盘一般不画边框,格线排成井字故得名。游戏需要的工具仅为纸和笔,然后由分别代表O和X的两个游戏者轮流在格子里留下标记(一般来说先手者为X),任意三个标记形成一条直线,则为获胜。
个人思路
1.先打印棋盘;
2.设计下棋思路;
3.判断胜负,这是最重要的一步;
写的有点长,请耐心看下去
头文件:
#ifndef _GAME__H_
#define _GAME__H_
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define ROW 4
#define COL 4
void InitBoard(char board[ROW][COL],int row,int col);
void DisplayBoard(char board[ROW][COL],int row,int col);
void ComputerMove(char board[ROW][COL],int row,int col);
void PlayerMove(char board[ROW][COL],int row,int col);
char IsWin(char board[ROW][COL],int row,int col);
#endif // _GAME__H_
初始化数组:
void InitBoard(char board[ROW][COL],int row,int col)
{
int i=0;
for(i