标签:namespace 提示 ble 描述 block panel ane row algorithm
斐波纳契数列是这样的数列:
f1 = 1
f2 = 1
f3 = 2
f4 = 3
....
fn = fn-1 + fn-2
输入一个整数n
求fn
一个整数n, n<= 40
一个整数fn
3
2
n<=40
#include <stdio.h> #include <stdlib.h> #include <string.h> #include<iostream> #include<stdio.h> #include<algorithm> using namespace std; int a[41]; int main() { int n; cin>>n; for(int i=3;i<=n;i++) { a[1]=1; a[2]=1; a[i]=a[i-2]+a[i-1]; } cout<<a[n]; return 0; }
标签:namespace 提示 ble 描述 block panel ane row algorithm
原文地址:http://www.cnblogs.com/suibingchen/p/6881762.html