簡體   English   中英

交流程序堆棧

[英]stack of a c program

如果輸入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

無恥的插件-看一下紐約市BSD用戶組的 GDB簡介演講 -那里有很多斐波那契堆棧跟蹤的例子。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM