c语言程序设计——三子棋(学期小作业)
2023-05-25
86 浏览
//test.c文件
#define _crt_secure_no_warnings 1
#include "game.h"
void menu()
{
printf("******************************\n");
printf("****** 1. play *****\n");
printf("****** 0. exit *****\n");
printf("******************************\n");
}
void game()
{
//存储数据 - 二维数组
char board[row][col];
//初始化棋盘 - 初始化空格
initboard(board, row, col);
//打印一下棋盘 - 本质是打印数组的内容
displayboard(board, row, col);
char ret = 0;//接受游戏状态
while (1)
{
//玩家下棋
playermove(board, row, col);
displayboard(board, row, col);
//判断玩家是否赢得游戏
ret = iswin(board, row, col);
if (ret != 'c')
break;
//电脑下棋
computermove(board, row, col);
displayboard(board, row, col);
//判断电脑是否赢得游戏
ret = iswin(board, row, col);
if (ret != 'c')
break;
}
" width="16" class="ne-image-loading-icon">
" width="16" class="ne-image-loading-icon">
" width="16" class="ne-image-loading-icon">
" width="16" class="ne-image-loading-icon">
请后发表内容