Question
I wish to know if this is a viable way to implement variable depth recursion so that I can run a function at each step and any better/other solutions to the description problem.
Description
Suppose I wish to have a function that fills an array either in pattern
x,y,x,y,x,y
where x and y are variables defined by some algorithm
and x,y,z,x,y,z
where x, y and z are variables defined by the same algorithm.
This should continue for all number of variables. Is this a viable way to implement it.
void recurse_n(int n)
{
while(n > 0)
{
--n;
recurse_n(n);
n = 0;
// Use algorithm here
}
}
EDIT: Removed the incorrect return type previously referred to. Brainfart.