Skip to content

Commit d9984ed

Browse files
authored
Merge pull request #27 from TORRYNN/2dArrays
Completed 2d Arrays
2 parents f327a97 + 0b89380 commit d9984ed

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

19_2D_Array/Question.class

-75 Bytes
Binary file not shown.

19_2D_Array/Question.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,20 @@ public static int Count(int[][] arr, int key) {
1515

1616
return count;
1717
}
18+
// Print out the sum of the numbers in the second row of the "nums" array;
19+
public static int sum(int mat[][]){
20+
int sum=0;
21+
for(int i=0; i<mat.length; i++){
22+
sum+=mat[1][i];
23+
}
24+
return sum;
25+
}
1826

1927
public static void main(String[] args) {
2028
int[][] array = { { 4, 7, 8 }, { 8, 8, 7 } };
2129
System.out.println(Count(array, 7)); // Output should be 2
30+
31+
int[][] nums = { {1,4,9},{11,4,3},{2,2,3} };
32+
System.out.println("Sum "+sum(nums));
2233
}
2334
}

0 commit comments

Comments
 (0)