12345678910111213141516171819202122232425262728293031
#include <iostream> #include <string> using namespace std; int main() { string Player1; string Player2; char board[3] [3] = {{ '1', '2', '3'},{'4', '5', '6'},{'7', '8', '9'}}; cout << "Enter the name of Player 1" << endl; getline (cin, Player1); cout << "Enter the name of Player 2" << endl; getline (cin, Player2); cout << Player1 << ": shall play as x's" << endl; cout << Player2 << ": shall play as o's" << endl; cout << board[1][1] <<" | " << board[1][2] << " | " << board[1][3] << " | " << endl; cout << board[2][1] <<" | " << board[2][2] << " | " << board[2][3] << " | " << endl; cout << board[3][1] <<" | " << board[3][2] << " | " << board[3][3] << " | " << endl; return 0; }
123456
for (int row = 0; row < 3; ++row) { for (int col = 0; col < 3; ++col) { cout << board[row][col] << " | "; } cout << endl; }