• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            技術,瞎侃,健康,休閑……

            mahu@cppblog 人類的全部才能無非是時間和耐心的混合物
            posts - 11, comments - 13, trackbacks - 0, articles - 12
              C++博客 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

            Fibonacci Freeze

            Posted on 2006-06-10 01:10 mahudu@cppblog 閱讀(341) 評論(0)  編輯 收藏 引用 所屬分類: C/C++

            The Fibonacci numbers (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ...) are defined by the recurrence:

            eqnarray20

            Write a program to calculate the Fibonacci Numbers.

            Input and Output

            The input to your program would be a sequence of numbers smaller or equal than 5000, each on a separate line, specifying which Fibonacci number to calculate.

            Your program should output the Fibonacci number for each input value, one per line.

            Sample Input

            5
            7
            11

            Sample Output

            The Fibonacci number for 5 is 5
            The Fibonacci number for 7 is 13
            The Fibonacci number for 11 is 89

            Solution

            #include <iostream>

            using namespace std;

            ?

            int main()

            {

            ?? int first,next,temp,n;

            ?? while(cin >> n) {

            ????? first = 0;

            ????? next = 1;

            ????? temp = 0;

            ????? if(n == 0 || n == 1) {

            ??????? cout << "The Fibonacci number for" << " " << n << " " << "is" << " " << n << endl;

            ????? }

            ????? else {

            ??????? for(inti = 2; i <= n; i++) {

            ?????????? temp = first + next;

            ?????????? first = next;

            ?????????? next = temp;

            ??????? }

            ??????? cout << "The Fibonacci number for" << " " << n << " " << "is" << " " << temp << endl;

            ????? }

            ?? }

            ?? return 0;

            }

            亚洲精品美女久久久久99| 久久婷婷五月综合成人D啪| 国产精品久久久久影院色| 久久无码av三级| 久久亚洲精品成人无码网站| 亚洲午夜久久久影院伊人| 国产精品狼人久久久久影院| 久久丝袜精品中文字幕| 精品久久久久久成人AV| 日韩欧美亚洲国产精品字幕久久久| 少妇内射兰兰久久| 人人狠狠综合久久亚洲高清| 精品久久久久久国产| 久久综合亚洲鲁鲁五月天| 91久久精品无码一区二区毛片| 久久久久久精品成人免费图片| 狠狠久久综合伊人不卡| 69SEX久久精品国产麻豆| 久久强奷乱码老熟女网站| 国产精品美女久久久久| 久久99精品久久久久久9蜜桃| 一本色道久久HEZYO无码| 精品久久久久久无码免费| 国产亚洲色婷婷久久99精品| 一本一本久久A久久综合精品| 久久av高潮av无码av喷吹| 91精品国产91热久久久久福利 | 久久最新免费视频| 国产精品青草久久久久婷婷| 久久久久久国产精品无码下载| 久久久中文字幕日本| 91久久精品国产免费直播| 嫩草影院久久国产精品| 婷婷久久久亚洲欧洲日产国码AV | 少妇久久久久久久久久| 久久婷婷人人澡人人爽人人爱| 久久久久久亚洲精品不卡| 欧美日韩成人精品久久久免费看| 久久精品国产亚洲麻豆| 66精品综合久久久久久久| 国产精品成人无码久久久久久 |