You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Flower/Untitled2.cpp

25 lines
314 B

#include<stdio.h>
int fibonacci(int n)
{
if(n<=1)
return 1;
return fibonacci(n-1)+fibonacci(n-2);
}
int main()
{
int n,x;
printf("请输入你想要得到的项:");
scanf("%d",&n);
int i;
for(i=0;i<=n;i++)
{
x=fibonacci(i);
printf("第%d个斐波那契数为%d\n",i,x);
}
return 0;
}