Question
creating an 2D array for my battleship game. Here what i have so far: #include using namespace std; const int ROWS = 10; const int
creating an 2D array for my battleship game. Here what i have so far:
#include
using namespace std;
const int ROWS = 10;
const int COLS = 10;
int main()
{
char board[ROWS][COLS];
for(int i = 0; i < ROWS; i++)
{
for(int j = 0; j < COLS; j++)
{
board[i][j] = '|';
}
}
for(int i = 0; i < ROWS; i++)
{
for(int j=0; j < COLS; j++)
cout << board[i][j] << " ";
cout << endl;
}
}
Here is the output that i need:
Enter firing coordinates !!! A 5
Hit !!!
Current Status
1 2 3 4 5 6 7 8 9 10
A | | | | | X | | | | | |
B | | | | | | | | | | |
C | | | | | | | | | | |
D | | | | | | | | | | |
E | | | | | | | | | | |
F | | | | | | | | | | |
G | | | | | | | | | | |
H | | | | | | | | | | |
I | | | | | | | | | | |
J | | | | | | | | | | |
Ammo remaining : 19
I need help creating rows A-J and Columns 1-10 so that when somone types in A 6, the X will go into the correct row/column
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