You are viewing a single comment's thread. Return to all comments →
public class Solution {
public static void main(String[] args) throws IOException { int sum; int maxsum = Integer.MIN_VALUE; int [][] a = new int[6][6]; Scanner sc = new Scanner(System.in); for(int i=0; i<6; i++){ for(int j=0; j<6; j++){ a[i][j]=sc.nextInt(); } } for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { if(i > 1 && j > 1) { 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); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Java 2D Array
You are viewing a single comment's thread. Return to all comments →
public class Solution {
//
System.out.println(maxsum); } }