-
-
Save codecademydev/f5d36c75cc26c9ca81030a2198c0f830 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include "def.hpp" | |
int main() { | |
std::vector<int> num = {1, 2, 3, 4, 5, 6, 7, 8, 9}; | |
int input = 0; | |
std::vector<char> block = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', }; | |
int turns = 0; | |
bool p1 = player1(block); | |
bool p2 = player2(block); | |
intro(block, num); | |
while ( turns < 4 && p1 == false && p2 == false) { | |
//----------Player 1 goes first----------------------- | |
std::cout << "\n\n"; | |
std::cout << "Player 1 turn (X)\n\n"; | |
no_num_board(block, num); | |
std::cin >> input; | |
std::cout << "\n\n"; | |
block = ex(block, input, num); | |
/*Shows the winner*/ | |
if (player1(block)) { | |
std::cout << "Player 1 wins!\n\n"; | |
no_num_board(block, num); | |
return 0; | |
} | |
else if (player2(block)) { | |
std::cout << "Player 2 wins!\n\n"; | |
no_num_board(block, num); | |
return 0; | |
} | |
//----------player 2 goes 2nd------------------------- | |
std::cout << "Player 2 turn (O)\n\n"; | |
no_num_board(block, num); | |
std::cin >> input; | |
std::cout << "\n\n"; | |
block = oh(block, input, num); | |
/*Shows the winner*/ | |
if (player1(block)) { | |
std::cout << "Player 1 wins!\n\n"; | |
no_num_board(block, num); | |
return 0; | |
} | |
else if (player2(block)) { | |
std::cout << "Player 2 wins!\n\n"; | |
no_num_board(block, num); | |
return 0; | |
} | |
turns++; | |
} | |
//---------Player 1 last turn------------ | |
std::cout << "Player 1 turn (X)\n\n"; | |
no_num_board(block, num); | |
std::cin >> input; | |
std::cout << "\n\n"; | |
block = ex(block, input, num); | |
/*Shows the winner*/ | |
if (player1(block)) { | |
std::cout << "Player 1 wins!\n\n"; | |
no_num_board(block, num); | |
return 0; | |
} | |
else if (player2(block)) { | |
std::cout << "Player 2 wins!\n\n"; | |
no_num_board(block, num); | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment