Task 3Create a static methodsumLeftRightDiagonals thataccepts any two 2D Square integerarrays of the same lengthand returns a 1D arraythat contains the left diagonal from the first array and the rightdiagonal from the second array and the last index of th

匿名用户 最后更新于 2021-11-29 17:10 计算机类Computing

Task 3

Create a static methodsumLeftRightDiagonals thataccepts any two 2D Square integerarrays of the same lengthand returns a 1D arraythat contains the left diagonal from the first array and the rightdiagonal from the second array and the last index of the 1D arrayis the sum of the left and right diagonal values.

You must usean enhanced for loop andall calculations must be performed inside the loop.

You may create anduse any helper methods insidethis method.

This is how it should start

int[][]G={{1,2,3},{4,5,6},{7,8,9}};

int[][]H={{0,2,3},{4,5,6},{2,8,1}};

0 1. 2 0 1 2 3 1 1. 4 5 6 2 7 8 9 0 1. 2 3 4. 5 6 = 0 1 5 9 3 5 2 25 0 1 2 0 0 2 3 1 4 5 6 SUM 2 2 18 1 01. 12 0 0 Maximum Value in Block 2 Minimum Value in Block 0 1. 6 2 Average Value in Block 3 5 2 3 2 4 0 1. 2 4 6 8 0 6 4.5 6 5 11 12 0 1 2 0 1 2 3 1. 2 3 4 5 6 7 8 هادی = 183 1 4 6 0 5 8 12 17 23 30 38 47 LO 00 2 7 9 0 1. 0 1. 3 0 1 = = 31 ס וס 0 3 5 9 14 1 4 //TASK 3 int[][] G = {{1,2,3},{4,5,6}, {7,8,9}}}| int[][] H = {{0,2,3},{4,5,6}, {2,8,1}}; display1DArray (sumLeftRightDiagonals (GH)); //TASK 4 int[][] ) = {{1,2}, {2,6},{3,5}, {2,4},{6,8},{11,12}}; display1DArray (blockStats (J)); //TASK 5 int[][] K = {{1,2,3},{4,5,6},{7,8,9}}; int[][] L = {{1,2}, {4,5}}; System.out.println((pseudoFibonacci(K))); System.out.println((pseudoFibonacci(L))); } 0 1. 2 0 1 2 3 1 1. 4 5 6 2 7 8 9 0 1. 2 3 4. 5 6 = 0 1 5 9 3 5 2 25 0 1 2 0 0 2 3 1 4 5 6 SUM 2 2 18 1

已邀请: