Guest User

Untitled

a guest
Jan 22nd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <map>
  2. #include <set>
  3. #include <list>
  4. #include <cmath>
  5. #include <ctime>
  6. #include <deque>
  7. #include <queue>
  8. #include <stack>
  9. #include <bitset>
  10. #include <cstdio>
  11. #include <vector>
  12. #include <cstdlib>
  13. #include <numeric>
  14. #include <sstream>
  15. #include <iostream>
  16. #include <algorithm>
  17.  
  18. using namespace std;
  19.  
  20. /* Complete the function below to print 2 integers separated by a single space which will be your next move
  21. */
  22. void nextMove(char player, vector <string> board){
  23. char prueba;
  24. vector <string> nume;
  25.  
  26. for(int cad = 0; cad <= 2; cad++){
  27. for(int car = 0; car <= 2; car++){
  28.  
  29. prueba = board[cad].at(car);
  30. if(prueba == '_'){
  31.  
  32. nume.push_back(car);
  33. }//end if
  34. }//end for
  35. }//end for
  36.  
  37. cout <<nume[rand() % nume.size()];
  38.  
  39. }//end nextMove
  40. int main() {
  41.  
  42. char player;
  43. vector <string> board;
  44.  
  45. //If player is X, I'm the first player.
  46. //If player is O, I'm the second player.
  47. cin >> player;
  48.  
  49. //Read the board now. The board is a 3x3 array filled with X, O or _.
  50. for(int i=0; i<3; i++) {
  51. string s; cin >> s;
  52. board.push_back(s);
  53. }
  54.  
  55. nextMove(player,board);
  56.  
  57. return 0;
  58. }
Add Comment
Please, Sign In to add comment