Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Augustus is the first king of the Roman kingdom.The Kingdom is now surrounded by enemies.the king wants to set his army all over the perimeter

Augustus is the first king of the Roman kingdom.The Kingdom is now surrounded by enemies.the king wants to set his army all over the perimeter of the kingdom to defend it from enemies. The whole area is divided into number of blocks.given a map of M N blocks,where 0 indicates Augustus's kingdom and all the other positive numbers indicate the enemies present in that particular block.The enemies present on all sides(left, right,up,down,and diagonals) of the perimeter are ready to attack the kingdom. King is preparing a war plan to defend the kingdom.Help the king by finding the number of enemies ready to attack the kingdom.
Write a java program that reads a matrix MN which represents the map and prints the number of enemies ready to attack the kingdom. First line of input contains two space-separated integers representing M and N respectively. The next M lines of input contains N space-separated integers..write a java program
for this problem immediately.

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

The Database Experts Guide To SQL

Authors: Frank Lusardi

1st Edition

0070390029, 978-0070390027

More Books

Students also viewed these Databases questions