public class MartixTraversal
public static void Main()
Traversal([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], 5, 5);
static void Traversal(int[] matrix, int rows, int columns)
for(int j = 0; j < rows; j++) {
Console.WriteLine("Columns; " + columns);
Console.WriteLine("Rows; " + rows);
for(int i = j * (columns + 1 + j); i < columns + (j * (columns + j)); i++) {
for(int i = j * (rows + 1 + j); i < rows * (rows - 1 + j); i += rows + j) {
for(int i = j * (columns + 1 + j); i > columns + (j * (columns + j)); i++) {
Console.WriteLine("Final result, layer " + j + ": " + matrix[i - matrix.Length - 1]);
for(int i = matrix.Length - 2; i >= matrix.Length - columns; i--) {
for(int i = rows * 2; i >= 0; i -= rows) {