Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Numerics;
- namespace MultidimensionArrays
- {
- class Program
- {
- static void Main(string[] args)
- {
- //int n = int.Parse(Console.ReadLine());
- int[,] matrix = new int[4,4]
- {
- {1, 2, 3, 4 },
- {5, 6, 7, 8 },
- {9, 10, 11, 12 },
- {13, 14, 15 ,16 }
- };
- //int[,] matrix = new int[n, n];
- //for (int i = 0; i < matrix.GetLength(0); i++)
- //{
- // for (int j = 0; j < matrix.GetLength(1); j++)
- // {
- // matrix[i, j] = int.Parse(Console.ReadLine());
- // }
- //}
- int rows = 0;
- int counter = 0;
- for (int row = matrix.GetLength(0) - 1; row >= 0; row--)
- {
- rows = row;
- for (int col = 0; col <= counter; col++)
- {
- Console.Write(matrix[rows, col] + " ");
- rows++;
- }
- Console.WriteLine();
- counter++;
- }
- int cols = 1;
- int counter2 = 0;
- for (int i = matrix.GetLength(0) - 2; i >= 0; i--)
- {
- for (int row = 0; row <= i; row++)
- {
- Console.Write(matrix[row, cols] + " ");
- cols++;
- }
- Console.WriteLine();
- counter2++;
- cols = 1 + counter2;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment