C++ 斐波那契数列递推算法实现 - 简答题
#include<cstdio> using namespace std; int main( ){ int f1=1,f2=1,n,t; cin>>n; for(int i=3;i<=n;i++){ t = f1+f2 ; f1 = f2; f2 = t; } cout<<f2; return 0; }
AI 优化版
原文地址:https://www.cveoy.top/t/topic/pGn0 著作权归作者所有。请勿转载和采集!
安全问答是一个知识全球问答,包含丰富的问答知识
#include<cstdio> using namespace std; int main( ){ int f1=1,f2=1,n,t; cin>>n; for(int i=3;i<=n;i++){ t = f1+f2 ; f1 = f2; f2 = t; } cout<<f2; return 0; }
原文地址:https://www.cveoy.top/t/topic/pGn0 著作权归作者所有。请勿转载和采集!