You are viewing a single comment's thread. Return to all comments →
int main() {
vector<vector<int>> arr(6); int maxHourGlassSum = -63; for (int i = 0; i < 6; i++) { arr[i].resize(6); string arr_row_temp_temp; getline(cin, arr_row_temp_temp); vector<string> arr_row_temp = split(rtrim(arr_row_temp_temp)); for (int j = 0; j < 6; j++) { int arr_row_item = stoi(arr_row_temp[j]); arr[i][j] = arr_row_item; } } for(int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { int hourGlassSum = arr[i][j] + arr[i][j+1] + arr[i][j+2] + arr[i+1][j+1] + arr[i+2][j] + arr[i+2][j+1]+ arr[i+2][j+2]; maxHourGlassSum = max(maxHourGlassSum, hourGlassSum); } } cout << maxHourGlassSum; return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Day 11: 2D Arrays
You are viewing a single comment's thread. Return to all comments →
In C++
int main() {
}