[Problem]
斐波纳契数列是这样的数列:
f1 = 1
f2 = 1
f3 = 2
f4 = 3
....
fn = fn-1 + fn-2
输入一个整数n
求fn
[Solution]
#include <iostream> using namespace std;int main(){int array[41];array[1] = 1;array[2] = 1;int n;cin >> n;for(int i = 3; i <= n; ++i){array[i] = array[i-1] + array[i-2];}cout << array[n] << endl;return 0; }