
1个回答
展开全部
讲太麻烦,写调用过程出来就行了。
int gcd(int u, int v)
{
printf("----fun stack----\n");
printf("this is gcd(%d, %d)\n", u, v);
if (v == 0) { printf("return %d", u); return u; }
else { printf("call gcd(%d, %d)\n", v, u%v); return gcd(v, u%v); }
}
结果:
----fun stack----
this is gcd(12, 32)
call gcd(32, 12)
----fun stack----
this is gcd(32, 12)
call gcd(12, 8)
----fun stack----
this is gcd(12, 8)
call gcd(8, 4)
----fun stack----
this is gcd(8, 4)
call gcd(4, 0)
----fun stack----
this is gcd(4, 0)
return 4
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询