Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void PrintMatrix(int[,] matrix)
- {
- int max = matrix[0, 0];
- foreach (int cell in matrix) max = Math.Max(max, cell);
- int cellSize = (int)Math.Log10(Math.Max(max, 1)) + 1;
- for (int i = 0; i < matrix.GetLength(0); i++)
- for (int j = 0; j < matrix.GetLength(1); j++)
- Console.Write(Convert.ToString(matrix[i, j]).PadRight(cellSize, ' ') + (j != matrix.GetLength(1) - 1 ? " " : "\n"));
- }
Advertisement
Add Comment
Please, Sign In to add comment