Home / Expert Answers / Computer Science / augustus-is-the-first-king-of-the-roman-kingdom-the-kingdom-is-now-surrounded-by-enemies-the-king-pa484

(Solved): Augustus is the first king of the Roman kingdom. The Kingdom is now surrounded by enemies. The king ...



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 a 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. The 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. The first line of input contains two space-separated integers representing M and N respectively. The next M lines of input contain N space-separated integers. Write a Java program for this problem immediately. note: i am giving so many times for inputs but the result of outputs are not exactly coming these two outupput exactly coming input: 4 4 4 2 1 3 3 2 0 3 2 0 0 2 5 0 4 2 output:10 input2: 2 2 0 2 0 4 output:6



We have an Answer from Expert

View Expert Answer

Expert Answer


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe