- #include <iostream>
- #include <random>
- #include <ctime>
- #include <cctype>
- #include <windows.h>
- #include "tic_tac_toe.h"
- using namespace std;
- Board::Board()
- /* Post: TheBoard is initialized as empty. */
- {
- for (int i = 0; i < 3; i++)
- for (int j = 0; j < 3; j++)
- squares[i][j] = 0;
- moves_done = 0;
- }
- void Board::instructions()
- {
- cout << "欢迎来到人机之战:" << endl
- << "规则:五子棋的简化版。。(井字棋)" << endl
- << "输入坐标进行游戏(能力所限) "<< endl << endl;
- cout << " x\\\\y1 2 3" << endl;
- for (int i = 0; i < 3; i++){
- cout << " " << i + 1 << " ";
- for (int j = 0; j < 3; j++){
- cout << "回";
- }
- cout << endl;
- }
- cout << endl;
- }
- void Board::print() const{
- system("cls");
- system("date /T");
- system("time /T");
- cout << endl << endl;
- cout << " x\\\\y1 2 3" << endl;
- for (int i = 0; i < 3; i++){
- cout << " " << i + 1 << " ";
- for (int j = 0; j < 3; j++){
- if (squares[i][j] == 1)
- cout << "□";
- else if (squares[i][j] == 2)
- cout << "
- //该片段来自于http://www.codesnippet.cn/detail/1011201410926.html
来源: http://www.codesnippet.cn/detail/1011201410926.html