gpt4 book ai didi

c - C程序的堆栈

转载 作者:行者123 更新时间:2023-11-30 16:04:29 25 4
gpt4 key购买 nike

如果我将输入设为 5,则以下程序的堆栈会是什么样子。

#include <stdio.h>

int fibonacci(int number)
{
int retval;
if (0 == number){
return 0;
}
if (1 == number){
return 1;
}
return(fibonacci(number-1) + fibonacci(number-2));
}

int main()
{
int number = 0;
int fibvalue = 1;
while (1){
printf("please enter the number\n");
scanf("%d", &number);
fibvalue = fibonacci(number);
printf("computed fibonacci value %d\n", fibvalue);
}
return 1;
}

还给我可以了解它的链接

最佳答案

使用调试器,例如GDB .

无耻插件-看看my GDB intro presentationNew York City BSD User Group - 那里有很多斐波那契堆栈跟踪的示例。

关于c - C程序的堆栈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3016625/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com