Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int Board[9] = {0,0,0,0,0,0,0,0,0};
- int P1, P2;
- bool Taken (int Board[],int x) {
- if(Board[x]!=0)
- return true;
- else
- return false;
- }
- bool Done(int * Board) {
- for(int i = 0; i < 9; i++)
- if(Board[i]!=0)
- return false;
- return true;
- }
- int main() {
- while (!Done(Board)){
- cout << "Player 1's turn." << endl;
- cin >> P1;
- if(Taken(Board, P1)) {
- cout << "That is taken, please select another" << endl;
- cin >> P1;
- }
- else {
- Board[P1] = 1;
- cout << "You have selected spot " << P1 << endl;
- }
- cout << "Player 2's turn." << endl;
- cin >> P2;
- if(Taken(Board, P2)) {
- cout << "That is taken, please select another" << endl;
- cin >> P2;
- }
- else {
- Board[P2] = -1;
- cout << "You have selected spot " << P2 << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement