fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <utility>
  4. using namespace std;
  5.  
  6. #include <iostream>
  7. #include <string>
  8.  
  9. using namespace std;
  10. void gameBoard();
  11. void drawGameBoard(string row1[], string row2[], string row3[]);
  12. void playerInput(string xOrO, string row1[], string row2[], string row3[]);
  13.  
  14. const int MAXLENGTH = 9;
  15.  
  16. int main()
  17. {
  18. gameBoard();
  19. }
  20.  
  21. void gameBoard()
  22. {
  23. string row1[] = { "__", "_", "__|", "__", "_", "__|", "__", "_", "__" };
  24. string row2[] = { "__", "_", "__|", "__", "_", "__|", "__", "_", "__" };
  25. string row3[] = { "__", "_", "__|", "__", "_", "__|", "__", "_", "__" };
  26.  
  27. drawGameBoard(row1, row2, row3);
  28. playerInput("X", row1, row2, row3);
  29. drawGameBoard(row1, row2, row3);
  30. }
  31.  
  32. void drawGameBoard(string row1[], string row2[], string row3[])
  33. {
  34. cout << endl;
  35. for (int i = 0; i < MAXLENGTH; ++i)
  36. {
  37. cout << row1[i];
  38. }
  39. cout << endl;
  40. for (int i = 0; i < MAXLENGTH; ++i)
  41. {
  42. cout << row2[i];
  43. }
  44. cout << endl;
  45. for (int i = 0; i < MAXLENGTH; ++i)
  46. {
  47. cout << row3[i];
  48. }
  49. cout << endl;
  50. cout << endl;
  51. }
  52.  
  53. void playerInput (string xOrO, string row1[], string row2[], string row3[])
  54. {
  55. row1[1] = xOrO;
  56. }
Success #stdin #stdout 0s 3416KB
stdin
Standard input is empty
stdout
_____|_____|_____
_____|_____|_____
_____|_____|_____


__X__|_____|_____
_____|_____|_____
_____|_____|_____