#include <iostream>
usingnamespace std;
int main ()
{
int waitForNumber;
// Named constants for array dimensions
constint ROWS = 3;
constint COLUMNS = 3;
char board[ROWS][COLUMNS] = {{' ',' ',' '},
{' ',' ',' '},
{' ',' ',' '}};
cout << "Here's the tic-tac-board: \n";
cout << " 1 2 3\n";
for (int i =1; i < ROWS; ++i)
{
cout << i << " ";
for (int j = 1; j < COLUMNS; ++j)
cout << board[i][j];
cout << endl;
}
// X makes the last move in the game
cout << "You get to make the first move.\nWhere do you want it to be? \n" << endl;
cout << "Row number is 0, 1,or 2.\nColumn number is 0, 1,or 2." << endl;
cout << "The final tic-tac-toe board for this game is: \n";
cout << " 1 2 3\n";
for (int i =1; i < ROWS; ++i)
{
cout << i << " ";
for (int j = 1; j < COLUMNS; ++j)
cout << board[i][j];
cout << endl;
}
cout << "\n'X' wins!" << endl << endl;
std::cin >> waitForNumber;
return 0;
}
Yes. You would put in code (presumably in the form of a loop) between lines 23 and 25 that would get the user's move, see if it's a valid move, check to see if the user won, make a computer's move, see if the computer won, and repeat until someone won.
An aside; if you have included the std namespace, why are you referring to cin as std::cin?
Also, your for loops should have i and j equal to 0 to begin with, not 0. If they start at one, each will get the value 1, then 2, and then the loop will stop.