#include<stdio.h>
int test1(int n)
{
if (n==1||n==2)
{
return 1;
}
else
{
return test1(n - 1) + test1(n - 2);
}
}
int main()
{
int n = 50;
for (int i = 1; i < n; i++)
{
printf("%d\n", test1(i));
}
return 0;
}
递归案例:斐波那契数列
最新推荐文章于 2024-07-12 18:02:43 发布