Advertisement
KonstantyNil

Untitled

Feb 10th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 KB | None | 0 0
  1. static void RectMultidimensionalArray()
  2.         {
  3.             Console.WriteLine("=> Rectangular multidimensional array: ");
  4.             // A rectangular multidimensional array.
  5.             int[,] myMatrix;
  6.             myMatrix = new int[3, 4];
  7.  
  8.             // Populate (3 * 4) array.
  9.             for(int i = 0; i < 3; i++) // Why there are no curly braces?
  10.             for(int j = 0; j < 3; j++) // Why there are no curly braces?
  11.             myMatrix[i,j] = i + j;
  12.  
  13.             // Print (3 * 4) array.
  14.             for (int i = 0; i < 3; i++)
  15.             {
  16.                 for (int j = 0; j < 4; j++)
  17.                     Console.WriteLine(myMatrix[i,j] + "\t");
  18.                 Console.WriteLine();
  19.             }
  20.             Console.WriteLine();
  21.         }
  22.  
  23.         static void RectMultidimensionalArray2()
  24.         {
  25.             Console.WriteLine("=> Rectangular multidimensional array: ");
  26.             // A rectangular multidimensional array.
  27.             int[,] myMatrix;
  28.             myMatrix = new int[3, 4];
  29.  
  30.             // Populate (3 * 4) array.
  31.             for (int i = 0; i < 3; i++)
  32.             {
  33.                 for (int j = 0; j < 3; j++)
  34.                 {
  35.                     myMatrix[i, j] = i + j;
  36.                 }
  37.             }
  38.                
  39.             // Print (3 * 4) array.
  40.             for (int i = 0; i < 3; i++)
  41.             {
  42.                 for (int j = 0; j < 4; j++)
  43.                     Console.WriteLine(myMatrix[i, j] + "\t");
  44.                 Console.WriteLine();
  45.             }
  46.             Console.WriteLine();
  47.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement