Вроде и не сложная задача, но решить не могу. Вот надо сделать рекурсию цикла tstRec1() (Там будет неизвестное число ) Я попробовал сделать в tstRec2(). Но не понятно как сделать именно сделать добавление именно в том порядке что в tstRec1() :
List<int> poh = new List<int>();
List<int> poh2 = new List<int>();
public void startTest()
{
tstRec2(2, 2);
tstRec1();
}
public void tstRec1()
{
for (int i = 0; i < 2; i++)
{
for (int u = 0; u < 2; u++)
{
for (int s = 0; s < 2; s++)
{
poh.Add(i);
poh.Add(u);
poh.Add(s);
}
}
}
}
public void tstRec2(int countZikls, int counter, int lvl = 0, int transport = 0)
{
for (int i = 0; i < counter; i++)
{
if (lvl > countZikls)
{
break;
}
else if (lvl == countZikls)
{
poh2.Add(i);
}
else
{
tstRec2(countZikls, counter, lvl+1, i);
}
}
}