> 其他 >
一. 应用递归算法输出Fibonacci数列前n个数.F1=1 F2=1 Fn=Fn-1+Fn-2
人气:196 ℃ 时间:2019-10-23 03:56:40
解答
#include
int GetFibonacci(int n)
{
if (n == 1 || n == 2) return 1;
else return GetFibonacci(n-1)+GetFibonacci(n-2);
}
void main()
{
int n;
scanf("%d",&n);
for (int i = 1; i
推荐
猜你喜欢
© 2024 79432.Com All Rights Reserved.
电脑版|手机版