Advertisement
Guest User

Untitled

a guest
Sep 17th, 2015
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1.         static void PrintArray(int[,] array)
  2.         {
  3.             int row = array.GetLength(0);
  4.             int col = array.GetLength(1);
  5.             double max = Math.Floor(Math.Log10(array.Cast<int>().Max())) + 2;
  6.             string format = "{0," + max +"}";
  7.  
  8.             Console.WriteLine(format);
  9.             for (int r = 0; r < row; r++)
  10.             {
  11.                 for (int c = 0; c < col; c++)
  12.                 {
  13.                     Console.Write(format, array[r, c]);
  14.                 }
  15.                 Console.WriteLine("");
  16.             }
  17.             Console.WriteLine("");
  18.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement