欧卡2中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

需要三步,才能开始

只需两步,慢速开始

玩欧卡就用莱仕达V10方向盘欧卡2入门方向盘选莱仕达V9莱仕达折叠便携游戏方向盘支架欢迎地图Mod入驻
查看: 2351|回复: 0
收起左侧

产生某两个数之间的斐波那契数列

[复制链接]
丶纠结灬 发表于 2011-11-10 20:40 | 显示全部楼层 |阅读模式
//产生某两个数之间的斐波那契数列
/* 
 * File:   main.cpp
 * Author: xuehaiyisu
 *
 * Created on 2011年9月5日, 23:21
 */

#include <cstdlib>
#include <iostream>
using namespace std;

int Fib(int n);

int main(int argc, char** argv)
{
    int min,max;
        cout<<"请输入数列区间"<<endl;
        cin>>min>>max;
        for(int i=min;i<=max;i++)
        {
                cout<<Fib(i)<<" ";
        }
        cout<<endl;
    system("pause");
    return 0;
}

int Fib(int n)
{
        if(n<2)
                return n;
        else
                return Fib(n-1)+Fib(n-2);
}

联系我们|手机版|欧卡2中国 ( 湘ICP备11020288号-1 )

GMT+8, 2024-4-27 11:06 , Processed in 0.122883 second(s), 8 queries , Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表