Do task 1 and task 2 in java Eclipse
Task 1
Create a static methodborderSum that accepts a 2DSquare integer array ofany length andreturns the sum of columns and rows asshown below. You must usean enhanced for loop andall calculations must be performed inside the loop. Youmay create and use anyhelper methods inside this method.
Task 2
Create a static methodfindCommon that acceptsany two 2D Square integer arrays of thesame length andreturns a 1D integer array that containsthe numbers that are common to both arrays. Youmust use an enhanced forloop and all checks must be performed inside theloop. You maycreate and use any helper methodsinside this method.
this is how task 1 and task 2 should look like whenmaking code
2 3 4. O 1 2 1 0 2 0 2 1 2 1. 2 3 = 40 1 2 3 1 4 6 7 2 3 1 8 9 2 7 3 5 4 = 34 5 6 2 3 8 2 7 8 9 3 1 2 5 4 1 1 3 0 1. 2 3 0 1 1 0 1 2 N N 1 5 1 3 0 1 2 3 2 6 8 1 2 1. 4 5 6 3 1 7 7 8 0 2 7 8 9 0 1 2 3 4 = 012 0 1 8 0 0 0 2 4 6 7 1 2 3 a 0 1 0 1 4 4 4 O 11 2 13 1 1 1 1 1 4 15 6 2 Oo oo 9 9 2 7 18 9 a a 3 a 9 //TASK 1 int[][] A = {{1,2,3},{4,5,6},{7,8,9}}; int[][] B = {{1,2,3,1,1},{4,6,7,2,2},{3,1,8,9,3}, {2,7,3,5,1},{5,1,1,1,3}}} System.out.println(borderSum(A)); System.out.println(borderSum(A)); //TASK 2 int[][] C = {{1,2,3},{4,5,6},{7,8,9}}; int[][] D = {{11,2,13},{4,15,6},{7,18,9}}; int[][] E = {{1,1,3,2},{5,1,3,2},{6,8,1,2},{1,7,8,0}}; int[][] F = {{1,4,4,4},{8,1,1,1},{9,9,9,9},{0,9,9,9}}; This display1DArray (findCommon (C,D)); you display1DArray (findCommon (E,F));
没有找到相关结果