C++:
Develop a simple Tc-Tac-Toe game between a human and the
computer.
Place the Tac-Tac-Toe board in an array of char (e.g., char
board[9] ) and use functions to create "operations" from which you
can build a game (see class notes, for example: reset(), Go(),
display(), etc.... avoid an over used of global variables, use
constants instead of pure numbers or characters, provide comments
for other programmers to see how your code works.
#include<iostream>
using namespace std;
char board[10]={'0','1','2','3','4','5','6','7','8','9'};
int checkwin();
void drawboard()
{
cout<<" "<<board[1]<<"|"<<board[2]<<"|"<<board[3]<<endl;
cout<<"--|-|--"<<endl;
cout<<" "<<board[4]<<"|"<<board[5]<<"|"<<board[6]<<endl;
cout<<"--|-|--"<<endl;
cout<<" "<<board[7]<<"|"<<board[8]<<"|"<<board[9]<<endl;
}
int main()
{
drawboard();
}
Get Answers For Free
Most questions answered within 1 hours.