#include<iostream>
#include<time.h>
#include<stdlib.h>
using namespace std;
const int N = 15;//棋盘大小
const char ChessBoardFlag = ' ';
const char flag1 = 'O';
const char flag2 = 'X';
typedef struct Coordinate
{
int x;
int y;
}ChessCoordi;
class FiveChess
{
public:
FiveChess()
{
InitChessBoard();
}
void Play()
{
ChessCoordi Pos1;
ChessCoordi Pos2;
while (1){
int mode = ChoseMode();
while (1){
if (mode == 1){//玩家VS电脑
static size_t count = 1;
PalyerGo(Pos1, 1, flag1);
if (count++ >= 9 && GetWiner(Pos1, 1, flag1))
break;
ComputerGo(Pos2, flag2);
if (count++ >= 10 && GetWiner(Pos2, 0, flag2))
break;
}
else if (mode == 2){//玩家VS玩家
static size_t count = 1;
PalyerGo(Pos1, 1, flag1);
if (count++ >= 9 && GetWiner(Pos1,1, flag1))
break;
PalyerGo(Pos2,2 ,flag2);
if (count++ >= 10 && GetWiner(Pos2,2, flag2))
break;
}
}
cout << "再来一局 y or no" << endl;
char chose = 'y';
cin >> chose;
if (chose == 'n')
break;
}
}
void PrintChessBoard()
{
system("cls");
for (size_t i = 0; i < N + 1; ++i)
{
for (size_t j = 0; j < N + 1; ++j)
09-09
02-27
07-23
2110
09-20
2993
03-16
159
05-28
07-23
6869