Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <map>
- #include <set>
- #include <list>
- #include <cmath>
- #include <ctime>
- #include <deque>
- #include <queue>
- #include <stack>
- #include <bitset>
- #include <cstdio>
- #include <vector>
- #include <cstdlib>
- #include <numeric>
- #include <sstream>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- /* Complete the function below to print 2 integers separated by a single space which will be your next move
- */
- void nextMove(char player, vector <string> board){
- char prueba;
- vector <string> nume;
- for(int cad = 0; cad <= 2; cad++){
- for(int car = 0; car <= 2; car++){
- prueba = board[cad].at(car);
- if(prueba == '_'){
- nume.push_back(car);
- }//end if
- }//end for
- }//end for
- cout <<nume[rand() % nume.size()];
- }//end nextMove
- int main() {
- char player;
- vector <string> board;
- //If player is X, I'm the first player.
- //If player is O, I'm the second player.
- cin >> player;
- //Read the board now. The board is a 3x3 array filled with X, O or _.
- for(int i=0; i<3; i++) {
- string s; cin >> s;
- board.push_back(s);
- }
- nextMove(player,board);
- return 0;
- }
Add Comment
Please, Sign In to add comment