Question: Program using Java. Write a function keepDiagonal (int[][] a) that takes a square 2D array (the number of columns equals the number of rows) as
Program using Java. Write a function keepDiagonal (int[][] a) that takes a square 2D array (the number of columns equals the number of rows) as an argument and returns a 2D array of int that is a copy of L, except that all the values not on the diagonal are set to 1. Examples show the diagonal in red.
For Example: shown above>
It is the following 2D ArrayList of Integer [[ 0, 0, 0, 0, [ 0, 0, 0, 0 l, [ 0, 0, 0, 0 l, [ 0, 0, 0, 0 ]] Ehen foo (L) would return the following 2D array: [ 0, 1, 1, 1 l, [ 1, 0, 1, 1], [ 1, 1, 0, 1 l, [ 1, 1, 1, 0 11
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
