Question: static void PrintPath(int[,] matrix, int[] path) { int rowsCount = matrix.GetLength(0); int colsCount = matrix.GetLength(1); int sum = 0; for (int row = 0; row
static void PrintPath(int[,] matrix, int[] path) { int rowsCount = matrix.GetLength(0); int colsCount = matrix.GetLength(1); int sum = 0; for (int row = 0; row < rowsCount; row++) { Console.WriteLine(); for (int col = 0; col < colsCount; col++) { string prefix = " "; string suffix = " "; if (col == path[row] - 1) { sum += matrix[row, col]; prefix = "["; suffix = "]"; } Console.Write(" {0}{1}{2} ", prefix, matrix[row, col], suffix); } } Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Sum of weights: {0}", sum); Console.WriteLine(); } This code is written in C#
Can you please write this code in C language, and give me a solution on where to store prefix ad suffix
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
