here is the code: #include <iostream> using namespace std; void printBoard(const
ID: 3753179 • Letter: H
Question
here is the code:
#include <iostream>
using namespace std;
void printBoard(const char b[][3], const int size);
void placeMove(char b[][3], int row, int col, char player);
int main() {
/* Type your code here. */
return 0;
}
Explanation / Answer
Given below is the code for the question.
Please do rate the answer if it was helpful. Thank you
#include <iostream>
using namespace std;
void printBoard(const char b[][3], const int size);
void placeMove(char b[][3], int row, int col, char player);
int main() {
int row, col;
char player;
const int size = 3;
char b[size][size];
//initialize
for(int r = 0; r < size; r++){
for(int c =0; c < size; c++){
b[r][c] = ' ';
}
}
printBoard(b, size);
cout << "Enter row: ";
cin >> row;
cout << "Enter column: ";
cin >> col;
cout << "Enter player character (X or O): ";
cin >> player;
cout << endl;
placeMove(b, row, col, player);
printBoard(b, size);
}
void printBoard(const char b[][3], const int size)
{
for(int r = 0; r < size; r++){
cout << "|";
for(int c =0; c < size; c++){
cout << b[r][c] << "|";
}
cout << endl;
}
cout << endl;
}
void placeMove(char b[][3], int row, int col, char player){
b[row][col] = player;
}
output
-----
| | | |
| | | |
| | | |
Enter row: 1
Enter column: 2
Enter player character (X or O): O
| | | |
| | |O|
| | | |
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.