• <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 閱讀(344) 評論(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;

            }

            久久久久久精品免费看SSS| 99久久精品免费看国产一区二区三区| 一本一道久久精品综合| 青青草原1769久久免费播放 | 久久久久无码精品国产app| 久久久久国产| 久久精品人人槡人妻人人玩AV | 香蕉aa三级久久毛片| 久久男人Av资源网站无码软件| 亚洲一本综合久久| 久久无码AV中文出轨人妻| 潮喷大喷水系列无码久久精品| 久久久不卡国产精品一区二区| 色欲综合久久躁天天躁蜜桃| 久久久久久国产a免费观看不卡| 午夜人妻久久久久久久久| 久久久久亚洲AV无码专区桃色| 色综合久久无码中文字幕| 久久99这里只有精品国产| 久久久久国产一区二区三区| 国产亚洲欧美精品久久久| 免费久久人人爽人人爽av| 久久综合伊人77777| 国产综合成人久久大片91| 久久精品国产91久久麻豆自制| 少妇熟女久久综合网色欲| 理论片午午伦夜理片久久 | 久久久午夜精品| 久久久久久亚洲精品不卡| 99久久免费只有精品国产| 国产精品久久毛片完整版| 久久精品国产99久久无毒不卡| 久久久久免费精品国产| 国产精品久久久久久久久久影院| 久久99久久无码毛片一区二区| 久久亚洲欧美日本精品| 色综合久久天天综合| 国产精品美女久久久| 亚洲国产精品久久久久婷婷老年| 91久久精一区二区三区大全| 91精品国产高清久久久久久国产嫩草 |