标签:
保存中间计算的结果
class Solution { public: int Fibonacci(int n) { if(n==0)return 0; if(n==1) return 1; int n0=0,n1=1,n2; while(--n) { n2=n0+n1; n0=n1; n1=n2; } return n2; } };
斐波那契数列
原文地址:http://www.cnblogs.com/daocaorenblog/p/5293308.html