Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- bool pl1Won();
- char board[9] = {'o','x','x','o','x','x','o','x','x'};
- int main()
- {
- //----------------------------------
- char pl1 = 'X';
- char pl2 = 'O';
- int choice;
- //----------------------------------------------------------------
- cout << "Welcome to the Tic Tac Toe game!\n" << "------------------------" << "\n\n";
- cout << "Player 1 has" " " << pl1;
- cout << "\nPlayer 2 has" " " << pl2 << endl << endl;
- //----------------------------------------------------------------
- cout << board[0] << "|" << board[1] << "|" << board[2] << endl;
- cout << board[3] << "|" << board[4] << "|" << board[5] << endl;
- cout << board[6] << "|" << board[7] << "|" << board[8] << endl << endl;
- //for()
- //{
- if(pl1Won() == true)
- {
- cout << "Player 1 has won!";
- }
- //}
- //
- cin.get();
- return 0;
- }
- bool pl1Won()
- {
- if (board[2] == 'x' && board[4] == 'x' && board[8] == 'x') // Else if() for the others
- {
- return true; // Win
- }else
- {
- return false; // Not yet
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement