class Solution { public: int Fibonacci(int n) { if (n != 0) { vector<int> array; array.push_back(1); array.push_back(1); int k = 2; while (k < 39) { array.push_back(array[k - 1] + array[k - 2]); ++k; } return array[n-1]; } else return 0; } };
原文:http://www.cnblogs.com/159269lzm/p/7260787.html