I need to write a program that tells the state of a Tic-Tac-Toe game, based off a board input by the user. The program needs to return a single character: X if x wins, O if o wins, or D if it is a draw, and * if none of those conditions exist. I'm supposed to write a function to do this, and call it in the main. I'm a bit stuck on how to go about doing this. So far all I have is a main function that prints the board after inputted by the user. Suggestions? Here's my code:
Code:#include <iostream> using namespace std; int main() { char board[3][3]; int i=0, j=0; cout << "Enter the board" << endl; for(i=0; i<3; i++) { for(j=0; j<3; j++) { cin >> board[i][j]; } } for(i=0; i<3; i++) { for(j=0; j<3; j++) { cout << board[i][j]; } cout << endl; } return 0; }



LinkBack URL
About LinkBacks


