#include
int feibo(int n)
{
int b,c,d;
if(n>=2)
{
b = 0;
c = 1;
d = b+c;
c = b;
b = d;
feibo(n-1);
}
else
{
printf("%d",d);
}
}
void main(){
int n =3;
getchar();
}
基于Monster 组和GPT的调写:
以下是修改后的代码:
#include<stdio.h>
int feibo(int n, int b, int c)
{
if(n==0)
{
return b;
}
else if(n==1)
{
return c;
}
else
{
int d = b + c;
return feibo(n-1, c, d);
}
}
int main()
{
int n = 3;
int result = feibo(n, 0, 1);
printf("%d", result);
return 0;
}
在操作系统中,栈是一个动态内存区域。
函数的中的局部变量,都存放在内存的栈区中。
栈区的使用,和数据结构中的栈使用规则相似:
压栈、出栈、先进后出。
栈区总是先使用高地址,再使用低地址,即栈区的使用是 从高地址向低地址延伸
的。