题目:http://www.nowcoder.com/practice/c6c7742f5ba7442aada113136ddea0c3
C++
class Solution {
public:
int Fibonacci(int n) {
if (n == ) return ;
if (n <= ) return ; int a = , b = ;
while(n-- > ) {
a = a + b;
b = a - b;
}
return a; }
};
题目:http://www.nowcoder.com/practice/c6c7742f5ba7442aada113136ddea0c3
C++
class Solution {
public:
int Fibonacci(int n) {
if (n == ) return ;
if (n <= ) return ; int a = , b = ;
while(n-- > ) {
a = a + b;
b = a - b;
}
return a; }
};