using
System;
using
System.Collections;
class
GFG{
static
void
matrix(
int
n,
int
m,
int
[,]li)
{
int
ctr = 0;
while
(ctr < 2 * n - 1)
{
for
(
int
i = 0;
i < Math.Abs(n - ctr - 1);
i++)
{
Console.Write(
" "
);
}
ArrayList lst =
new
ArrayList();
for
(
int
i = 0; i < m; i++)
{
for
(
int
j = 0; j < n; j++)
{
if
(i + j == ctr)
{
lst.Add(li[i, j]);
}
}
}
for
(
int
i = lst.Count - 1;
i >= 0; i--)
{
Console.Write((
int
)lst[i] +
" "
);
}
Console.Write(
"\n"
);
ctr += 1;
}
}
public
static
void
Main(
string
[] args)
{
int
n = 8;
int
m = n;
int
[,] li = {{4, 5, 6, 9, 8, 7, 1, 4},
{1, 5, 9, 7, 5, 3, 1, 6},
{7, 5, 3, 1, 5, 9, 8, 0},
{6, 5, 4, 7, 8, 9, 3, 7},
{3, 5, 6, 4, 8, 9, 2, 1},
{3, 1, 6, 4, 7, 9, 5, 0},
{8, 0, 7, 2, 3, 1, 0, 8},
{7, 5, 3, 1, 5, 9, 8, 5}};
matrix(n, m, li);
}
}