Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a java program that receives m and n as the number of rows and columns of the grid, respectively. In the second line, the

Write a java program that receives m and n as the number of rows and columns of the grid, respectively. In the second line, the user inputs an integer, b, showing the number of bombs placed in the grid. It then follows by b lines of input from the user, each referring to the row and column index of each one of the bombs. After receiving grid dimensions, the number of bombs, and bomb locations, you will need to display (print) the completed grid showing the bomb cells with * and safe cells with the number of neighboring bombs to that cell.

Sample Input 1:

2 2 2 0 0 1 1 

Sample Output 1:

* 2 2 * 

Sample Input 2:

5 3 4 1 2 2 2 4 0 4 1 

Sample Output 2:

0 1 1 0 2 * 0 2 * 2 3 2 * * 1 

Sample Input 3:

4 7 7 0 0 1 1 2 2 3 3 2 4 1 5 0 6 

Sample Output 3:

* 2 1 0 1 2 * 2 * 2 2 2 * 2 1 2 * 3 * 2 1 0 1 2 * 2 1 0 

Sample Input 4:

2 6 5 0 1 1 0 1 1 1 2 1 5 

Sample Output 4:

3 * 3 1 1 1 * * * 1 1 * 

Sample Input 5:

3 3 9 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 

Sample Output 5:

* * * * * * * * *

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

Students also viewed these Databases questions