Originally Posted by
smitsky
Actually, I believe that this function is an example of recursion. I really do mean fn(x-y,y). Maybe it should be:
Code:
...
temp=x;
x=y;
y=temp;
...
That would be my guess. Did you try it? What did you intend this code to do? (Or, if you got it from someone/somewhere else, what do you think it's supposed to do?)
Heres an example of what you could try to do to track it down yourself:
Code:
int fn(int x, int y)
{
int retval;
if(x==y)
return x;
if(x<y)
{
int temp;
temp=x;
x=y;
y=x;
}
cout << "before calling fn(" << x-y << ", " << y << ")" << endl;
retval = fn(x-y,y);
cout << " returning from fn(), with retval = " << retval << endl;
return retval;
}
cout<< is a wonderful debugging tool.
Regards,
Dave