#include<iostream>
using namespace std;
int main()
{
int a=1,b=1;
int temp;
int flag = 0;
int num;
cin>>num;
if(num)
cout<<a<<" ";
while(num--)
{
cout<<b<<" ";
temp = b;
b+=a;
a = temp;
}
system("pause");
return 0;
}非递归的斐波那契数列,数据大了就不行了。权当练习
简单的斐波那契数列程序
最新推荐文章于 2024-04-17 22:54:26 发布
本文介绍了一种非递归的方式实现斐波那契数列,并通过C++代码进行了展示。该方法适用于生成较大数值的斐波那契数列,但有一定的局限性。
8万+

被折叠的 条评论
为什么被折叠?



