Question
attempting to do this in c++, sorry, ignore formatting for now Johns Board Freds Board 1 2 3 4 5 6 1 2 3 4
attempting to do this in c++, sorry, ignore formatting for now
Johns Board Freds Board
1 2 3 4 5 6 1 2 3 4 5 6
1 * * * * * * 1 * * * * * *
2 * * * * * * 2 * * * * * *
3 * * * * * * 3 * * * * * *
4 * * * * * * 4 * * * * * *
5 * * * * * * 5 * * * * * *
6 * * * * * * 6 * * * * * *
// trying to print out a battle ship game grid and having trouble just passing the arrays, we plan on using the * to show areas that need to be guessed #include #include using namespace std;
void astrik(char array1[], int a, int b) { int i; int j;
for(i = 0; i < a; ++i) { for (j = 0; j < b; ++j) { array1[i][j] = '*'; } } return; }
void print(char array1[], int a, int b, char array2[], int c, int d, string str1, string str2) { int i; int j; int k; int l; int m;
cout << str1 << "'s Board \t" << str2 << "'s Board" << endl;
cout << "\t";
for (l = 0, l < a, ++l) { cout << l + 1 << "\t"; } cout << "\t"; for (m = 0, m < a, ++m) { cout << m + 1 << "\t"; }
for (i = 0; i < a; ++i) { cout << i + 1 << "\t"; for (j = 0; j < b; ++j) { cout << array1[i][j] << "\t"; } cout << "/t" << i + 1; for (k = 0; k < b; ++k) { cout << array2[i][k] << "\t"; } cout << endl; } return; }
int main() {
string player1Name = "Noah"; string player2Name = "Sam";
int row = 5; int col = 5;
char player1Board[row][col]; char player2Board[row][col];
astrik(player1Board, row, col); astrik(player2Board, row, col);
print(player1Board, row, col, player2Board, row, col, player1Name, player2Name);
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started