Hi guys, i am trying to make a recursive function but I am having some troubles.
If the first if is true several times, calling the function herself over and over again when all of the recursive calls ends and the program reaches the second if of the first "checkFour" call, (the original one) the value of "int dist" should be the same of the arg of the first invoke, right?
For "arg of the first invoke" i mean checkFour(, , THIS ONE);
void checkFour(int x, int y, int dist)
{
int xx = x;
int yy = y;
xx++;
if(!vrf(x, y, xx, yy) && check(xx, yy, dist))
{
intt.push_back(getStr(x, y, xx, yy));
checkFour(xx, yy, dist + 1);
}
xx -= 2;
if(!vrf(x, y, xx, yy) && check(xx, yy, dist))
{
intt.push_back(getStr(x, y, xx, yy));
checkFour(xx, yy, dist + 1);
}
xx++;
yy++;
if(!vrf(x, y, xx, yy) && check(xx, yy, dist))
{
intt.push_back(getStr(x, y, xx, yy));
checkFour(xx, yy, dist + 1);
}
yy -= 2;
if(!vrf(x, y, xx, yy) && check(xx, yy, dist))
{
intt.push_back(getStr(x, y, xx, yy));
checkFour(xx, yy, dist + 1);
}
}```