static void FindMaxSum(int[,] matrix, int n, int m) { // This finds the biggest platform int maxSum = int.MinValue; int[,] platform = new int[3, 3]; int maxCol = 0; int maxRow = 0; for (int row = 1; row < n - 1; row++) { for (int col = 1; col < m - 1; col++) { platform = RectangularMatrixSum.FillPlatform(matrix, row, col); int currentSum = RectangularMatrixSum.SumPlatform(platform); if (currentSum > maxSum) { maxCol = col; maxRow = row; maxSum = currentSum; } } } RectangularMatrixSum.PrintResult(RectangularMatrixSum.FillPlatform(matrix, maxRow, maxCol), maxSum); }
static void FillMatixWithUserInput(int[,] matrix, int n, int m) { // This gets the user to input each and every for (int row = 0; row < n; row++) { for (int col = 0; col < m; col++) { col = RectangularMatrixSum.InputLine(matrix, row, col); } } }
static void Test() { // This is a test matrix i've used during the testing of the program RectangularMatrixSum.FindMaxSum(new int[, ] { { 1, 2, 3, 5, 2, 52, 48, 56 }, { 2, 3, 5, 72, 3, 72, 52, -50 }, { 4, 16, 19, 2, 3, 4, -20, 15 }, { 42, 15, 0, -10, 20, 15, -20, 60 }, { 5, 8, 16, 9, 15, 2, -3, -15 }, { 6, 9, 5, 9, 10, -15, 55, 5 } }, 6, 8); }
static void GetMaxPlatformWithUserInput() { // This part gets the user input Console.Write("Please input a valid integer for the N (it should be > 3): "); int n = int.Parse(Console.ReadLine()); Console.Write("Please input a valid integer for the M (it should be > 3): "); int m = int.Parse(Console.ReadLine()); int[,] matrix = new int[n, m]; RectangularMatrixSum.FillMatixWithUserInput(matrix, n, m); RectangularMatrixSum.FindMaxSum(matrix, n, m); }