Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
//standard library
using namespace std; //allows the use of cout & endl without "std::" prefix.
char matrix[3][3] = { '1', '2', '3', '4', '5', '6', '7', '8', '9' }; //TicTacToe board array labeled
'matrix'.
char player = 'X'; //initializes player as 'X'
//prompts the user for position on TicTacToe & saves input to 'a'.
cout << "Enter the number of the desired position: ";
cin >> a;
//second player
if (matrix[0][0] == 'O' && matrix[0][1] == 'O' && matrix[0][2] == 'O')
return 'O';
if (matrix[1][0] == 'O' && matrix[1][1] == 'O' && matrix[1][2] == 'O')
return 'O';
if (matrix[2][0] == 'O' && matrix[2][1] == 'O' && matrix[2][2] == 'O')
return 'O';
return '/';
}