class Solution {
public:
int Fibonacci(int n) {
if(n==0)
return 0;
else if(n==1)
return 1;
else{
int a = 0;
int b = 1;
int temp;
while(n>1)
{
temp = a;
a = b;
b = temp+b;
n--;
}
return b;
}
}
};
斐波那契数列
最新推荐文章于 2024-07-25 21:13:04 发布