Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void RectMultidimensionalArray()
- {
- Console.WriteLine("=> Rectangular multidimensional array: ");
- // A rectangular multidimensional array.
- int[,] myMatrix;
- myMatrix = new int[3, 4];
- // Populate (3 * 4) array.
- for(int i = 0; i < 3; i++) // Why there are no curly braces?
- for(int j = 0; j < 3; j++) // Why there are no curly braces?
- myMatrix[i,j] = i + j;
- // Print (3 * 4) array.
- for (int i = 0; i < 3; i++)
- {
- for (int j = 0; j < 4; j++)
- Console.WriteLine(myMatrix[i,j] + "\t");
- Console.WriteLine();
- }
- Console.WriteLine();
- }
- static void RectMultidimensionalArray2()
- {
- Console.WriteLine("=> Rectangular multidimensional array: ");
- // A rectangular multidimensional array.
- int[,] myMatrix;
- myMatrix = new int[3, 4];
- // Populate (3 * 4) array.
- for (int i = 0; i < 3; i++)
- {
- for (int j = 0; j < 3; j++)
- {
- myMatrix[i, j] = i + j;
- }
- }
- // Print (3 * 4) array.
- for (int i = 0; i < 3; i++)
- {
- for (int j = 0; j < 4; j++)
- Console.WriteLine(myMatrix[i, j] + "\t");
- Console.WriteLine();
- }
- Console.WriteLine();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement