用递归的思想求斐波那契数

来源:互联网 发布:2017年网络大电影榜单 编辑:程序博客网 时间:2024/06/06 05:32
#include <iostream>using namespace std;int f (int x){    if(x<=1)        return x;    else    {        return f(x-2)+f(x-1);    }}int main (){    int n;    cin >> n;    cout << f(n) << endl;    return 0;}