第1个回答 2013-05-30
#include <stdio.h>
int fbnc(int num)
{
if (1 == num || 2 == num)
{
return 1;
}
else
{
return fbnc(num-2) + fbnc(num-1);
}
}
int main()
{
int num = 20;
int i=0;
int amount = 0;
printf("Fibonacci[20]:");
for (i=1; i<=num; i++)
{
printf("%d ", fbnc(i));
amount += fbnc(i);
}
printf("\n");
printf("amount:%d\n", amount);
}本回答被网友采纳