Please Help! Printing row/column labels

I need to print the row/column labels of my game board. It is a 10 by 10 board for a battle ship game. I am unsure of how to do this. DO I have to create an array? & if yes how can I have it for the row and column to print like this: I got the O to print just need the labels. I have a function that does this.

0 1 2 3 4 5 6 7 8 9
0 O O O O O O O O O O
1 O O O O O O O O O O
2 O O O O O O O O O O
3 O O O O O O O O O O
4 O O O O O O O O O O
5 O O O O O O O O O O
6 O O O O O O O O O O
7 O O O O O O O O O O
8 O O O O O O O O O O
9 O O O O O O O O O O

My function code is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

void print_board(char ocean [][S])
{
    
    for (int i=0; i<10; i++)
        
    {
        for(int j=0; j<10; j++)
        {
            
            cout<< ocean[i][j]<< " ";
			
        }
        cout<< endl;
    }
}


Last edited on
Topic archived. No new replies allowed.