Thanks,
Ryan
Here is the code:
// Tic Tac Toe 1.0
// Ryan Vowell
// Programming Fundamentals 1
#include <iostream>
char board[3][3] = { {0,0,0} , {0,0,0} , {0,0,0} }; //keeps track of X's and O's
void display(); // displays board
bool checkForWin(); // checks for win
main()
{
int row;
int column;
bool win = false;
display();
while(win == false)
{
std::cout << "Player One's turn - " << std::endl; //Player One
std::cout << "Row: ";
std::cin >> row;
std::cout << "Column: ";
std::cin >> column;
board [row - 1][column - 1] = 'X';
display();
checkForWin();
std::cout << "Player Two's turn - " << std::endl; // Player Two
std::cout << "Row: ";
std::cin >> row;
std::cout << "Column: ";
std::cin >> column;
board [row - 1][column - 1] = 'O';
display();
checkForWin();
};
return 0;
}
void display() //board
{
std::cout<<"\n\t\t 1 2 3\n"<<std::endl;
std::cout<<"\t\t 1 "<<board[0][0]<<" | "<<board[0][1]<<" | "<<board[0][2]<<std::endl;
std::cout<<"\t\t ---|---|---\n";
std::cout<<"\t\t 2 "<<board[1][0]<<" | "<<board[1][1]<<" | "<<board[1][2]<<std::endl;
std::cout<<"\t\t ---|---|---\n";
std::cout<<"\t\t 3 "<<board[2][0]<<" | "<<board[2][1]<<" | "<<board[2][2]<<"\n\n\n";
}
bool checkForWin() //checks for win
{
bool win;
return win;
}

New Topic/Question
Reply




MultiQuote






|