求解,为什么后面输出的都是0?
#include<stdio.h>
int fibo(int n);
int main()
{
int n = 1, result;
while (n <= 30)
{
result = fibo(n);
printf("%d\n", result);
n++;
}
return 0;
}
int fibo(int n)
{
int str[30] = {1,1};
if (n == 1 || n == 2)
{
return str[n - 1];
}
else
{
str[n - 1] = str[n - 2] + str[n - 3];
return str[n - 1];
}
}