剑指OFFER 斐波那契数列
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;
}
};