Created
October 19, 2017 01:05
-
-
Save jfsr/d4f2f1a03646d52825182acb65b196bb to your computer and use it in GitHub Desktop.
Day 11: 2D Arrays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int maximum = arr[0][0] + arr[0][1] + arr[0][2] + arr[1][1] + arr[2][0] + arr[2][1] + arr[2][2]; | |
int tempMax = 0; | |
for(int x = 1; x <= 4; x++){ | |
for(int y = 1; y <= 4; y++){ | |
tempMax = arr[x-1][y-1] + arr[x-1][y] + arr[x-1][y+1] + arr[x][y] + arr[x+1][y-1] + arr[x+1][y] + arr[x+1][y+1]; | |
if(tempMax > maximum){ | |
maximum = tempMax; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment