标签:int code ret i++ fibonacci 数列 return pre 斐波那契
class Solution {
public:
int Fibonacci(int n) {
int n1 = 1;
int res = 1;
if(n == 0)return 0;
if(n == 1)return 1;
if(n == 2)return 1;
for(int i=0;i<n-2;i++)
{
int t = n1 + res;
n1 = res;
res = t;
}
return res;
}
};
标签:int code ret i++ fibonacci 数列 return pre 斐波那契
原文地址:https://www.cnblogs.com/virgildevil/p/12182431.html