I need help with this hw problem.

Generate a 2-D array of 25 integers and initialize them all to 0. Assign the value 9 to five random locations in the array to represent your mines. Fill the remaining array locations by counting the number of mines in any adjacent squares. Display the filled array.

I got the array filled in with the mines (9's) and the rest with 0's. I'm having trouble filling in the rest of the array with counting the number of mines in any adjacent squares.

I get this

9 0 0 0 0

0 9 0 9 0

0 0 0 0 0

9 0 0 0 0

0 0 9 0 0

When I want this

9 2 2 1 1

2 9 2 9 1

2 2 2 1 1

9 2 1 1 0

1 2 9 1 0

Any help would be appreciated. Thanks