刚学C++没多久
心血来潮写了个井字棋,其中肯定有非常多值得优化的地方,一起交流吧
第一个CPP文件:
#include<iostream>
using namespace std;
#include<string>
#include"print_chessBoard.h"
extern char chessBoard[3][3];
extern int step_chess;
int flag_win = 0 ;
void print_chessBoard()//这个函数的逻辑是参考一篇文章 然后自己修改了一点
{
for (int row = 2; row > -1; row--) {
printf("| %c | %c | %c |\n",
chessBoard[row][0],chessBoard[row][1], chessBoard[row][2]);
}
}
void judgment()
{
for (size_t i = 0; i < 3; i++)
{
if (chessBoard[i][0] == 0x58 && chessBoard[i][1] == 0x58 && chessBoard[i][2] == 0x58)
{
flag_win = 2;
}
if (chessBoard[i][0] == 0x30 && chessBoard[i][1] == 0x30 && chessBoard[i][2] == 0x30)
{
flag_win = 1;