using
System;
using
System.Collections.Generic;
public
class
GFG {
static
List<
int
> s =
new
List<
int
>();
static
List<
int
> d =
new
List<
int
>();
static
int
m = 2, n = 3;
static
void
printList(List<
int
> path,
int
[,] mat)
{
int
cnt = path.Count;
for
(
int
i = 0; i < cnt; i += 2)
Console.Write(mat[path[i],path[i + 1]] +
" "
);
Console.WriteLine();
}
static
void
countPaths(
int
i,
int
j,
List<
int
> path,
int
[,] mat)
{
if
(i > d[0] || j > d[1])
return
;
path.Add(i);
path.Add(j);
if
(i == d[0] && j == d[1]) {
printList(path, mat);
path.RemoveAt(path.Count - 1);
path.RemoveAt(path.Count - 1);
return
;
}
countPaths(i, j + 1, path, mat);
countPaths(i + 1, j, path, mat);
path.RemoveAt(path.Count - 1);
path.RemoveAt(path.Count - 1);
}
public
static
void
Main(String[] args)
{
int
[,] mat = { { 1, 2, 3 }, { 4, 5, 6 } };
s.Add(0);
s.Add(0);
d.Add(1);
d.Add(2);
List<
int
> path =
new
List<
int
>();
countPaths(s[0], s[1], path, mat);
}
}