Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- public class Program
- {
- public static void Main()
- {
- int[,] mn =
- {
- {0, 2, 4, 0, 9, 5},
- {7, 1, 3, 3, 2, 1},
- {1, 3, 9, 8, 5, 6},
- {4, 6, 7, 9, 1, 0},
- };
- int bestSum = int.MinValue;
- int bestCol = 0;
- int bestRow = 0;
- for(int row = 0; row < mn.GetLength(0) - 1 ; row++)
- {
- for(int col = 0; col < mn.GetLength(1) - 1; col++)
- {
- int sum = mn[row, col] + mn[row+1, col] + mn[row, col+1] + mn[row+1, col+1];
- if(sum > bestSum)
- {
- bestRow = row;
- bestCol = col;
- bestSum = sum;
- }
- }
- }
- Console.WriteLine("The best platform is:");
- Console.WriteLine(" {0}, {1}", mn[bestRow, bestCol], mn[bestRow, bestCol+ 1]);
- Console.WriteLine(" {0}, {1}", mn[bestRow + 1, bestCol], mn[bestRow + 1, bestCol + 1]);
- Console.WriteLine("The best sum is: {0}", bestSum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment