I have a piece of code consisting of k nested for loops, for example:
int k = 5;
int *p = new int[k];
double x,y; //x is read from file
for(p[0]=0;p[0]<=6;p[0]++)
for(p[1]=0;p[1]<=3;p[1]++)
for(p[2]=0;p[2]<=3;p[2]++)
for(p[3]=0;p[3]<=3;p[3]++)
for(p[4]=0;p[4]<=3;p[4]++)
y = assign(x, p);
This works, however, in a more general version k can be anywhere from
1 to 10. Therefore p will be of array size k and range from p[0] to
p[k-1], and I will only need k number of nested for loops. I could
write code for all the different possible conditions and use if
statements to select the proper one, but i would rather see if there
is a way to do it in a more compact manner (like with a recursive
function or even using the goto statement).