-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJava 2D Array
34 lines (28 loc) · 860 Bytes
/
Java 2D Array
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;
public class Solution {
private static final Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int[][] a = new int[6][6];
int maxSum = Integer.MIN_VALUE;
try (Scanner scanner = new Scanner(System.in);)
{
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 6; j++) {
a[i][j] = scanner.nextInt();
if(i>1 && j>1)
{
int sum =a[i][j]+ a[i][j-1]+ a[i][j-2]+ a[i-1][j-1]+ a[i-2][j]+ a[i-2][j-1]+ a[i-2][j-2];
if (sum > maxSum) {maxSum = sum;}
}
}
}
}
System.out.println(maxSum);
}
}