char board[ROW][COL] = { 0 };//二维数组的初始化并没有这么简单
printf(“——————————-\n”);
printf(“——————————-\n”);
printf(“—-1.play 0.exit——–\n”);
printf(“——————————-\n”);
printf(“——————————-\n”);
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)
if (board[x - 1][y - 1] == ' ')
board[x - 1][y - 1] = 'X';
void ComputerMove(char board[ROW][COL], int row, int col)
if (board[x - 1][y - 1] == ' ')
board[x - 1][y - 1] = 'O';
int IsFull(char board[ROW][COL], int row, int col)
char Iswin(char board[ROW][COL], int row, int col)
if (board[i][0] == board[i][1] && board[i][1] == board[i][2] && board[i][1] != ' ')
return board[i][0];//Iswin直接结束
if (board[0][i] == board[1][i] && board[1][i] == board[2][i] && board[1][i] != ' ')
if (board[0][0] == board[1][1] && board[1][1] == board[2][2] && board[1][1] != ' ')
if (board[0][2] == board[1][1] && board[1][1] == board[2][0] && board[1][1] != ' ')
srand((unsigned int)time(NULL));//扩大电脑走的随机值范围

您可以选择一种方式赞助本站