初来驾到,请多指教
大佬们,怎样列出斐波那契数列1到50位?
先搜索一哈
https://bbs.bccn.net/viewthread.php?tid=498536&highlight=
程序代码:#include <iostream>
int main( void )
{
unsigned long long a=1, b=0;
for( unsigned i=0; i!=50; ++i )
{
b = b + a;
a = b - a;
std::cout << b << '\n';
}
}
程序代码:#include <iostream>
#include <cstdint>
int main( void )
{
uint64_t a=1, b=0;
for( unsigned i=0; i!=50; ++i )
{
b = b + a;
a = b - a;
std::cout << b << '\n';
}
}