• <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>

            JonsenElizee

            Software Developing Blog

            "An idea is fragile . It can be killed by a scornful smile or a yawn .It can be mound down by irony and scared to death by a cold look."
            "Most cultures throughout human history have not liked creative individuals .They ignore them or kill them.It is a very efficient way of stopping creativity."

            ------Advertising boss Charles Browe and Howard Gardner ,professor at Harvard

               :: 首頁 :: 新隨筆 ::  ::  :: 管理 ::
            How to avoiding duplicated computing of recursive function like this one:
            func(n) = func(n-1) + func(n-2) + func(n-3) and func(1) == func(2) == 1 and func(3) == 2.
            or function like this: fabonaci:
            fabonaci(n) = fabonaci(n-1) + fabonaci(n-2).


             1 int fabo(int n, int* ptr)
             2 {
             3     printf("fabo(%d)\n", n);
             4     if(n < 3
             5     {
             6         *ptr = 1;
             7         return 1;
             8     }
             9     else {
            10         int tmp;
            11         *ptr = fabo(n - 1&tmp);
            12         
            13         return *ptr + tmp;
            14     }
            15 }
            16 int fabonaci(int n)
            17 {
            18     int tmp;
            19     return fabo(n, &tmp);
            20 }
            21 
            22 int xxx(int n)
            23 {
            24     printf("xxx(%d)\n", n);
            25     if(n < 3)return 1;
            26     else return xxx(n-1)+xxx(n-2);
            27 }
            28 int main()
            29 {
            30     int n = fabonaci(10);
            31     printf("n = %d\n", n);
            32 
            33     n = xxx(10);
            34     printf("n = %d\n", n);
            35     getchar();
            36     return 0;
            37 }

             1 /************************************************************************/
             2 /* func(n) = func(n-1) + func(n-2) + func(n-3)                          */
             3 /* func(1) = 1; func(2) = 1; func(3) = 2;                               */
             4 /************************************************************************/
             5 int funk(int n, int* n_1, int* n_2)
             6 {
             7     printf("funk(%d)\n", n);
             8     if(n == 3){
             9         *n_1 = 1;
            10         *n_2 = 1;
            11         return 2;
            12     }
            13     else{
            14         int n_1_1, n_1_2;
            15         *n_1 = funk(n-1&n_1_1, &n_1_2);
            16         *n_2 = n_1_1;
            17         return *n_1 + *n_2 + n_1_2;
            18     }
            19 }
            20 int func(int n)
            21 {
            22     int n_1, n_2;
            23     return funk(n, &n_1, &n_2);
            24 }
            25 int main()
            26 {
            27     int n = func(10);
            28     printf("n = %d\n", n);
            29     getchar();
            30     return 0;
            31 }

            posted on 2010-10-20 11:48 JonsenElizee 閱讀(1267) 評論(0)  編輯 收藏 引用 所屬分類: Data Structures & Algorithms
            By JonsenElizee
            久久久久亚洲AV成人网人人网站| 久久伊人五月丁香狠狠色| 91久久婷婷国产综合精品青草| 亚洲国产欧美国产综合久久| 国产精品久久久福利| 久久丫忘忧草产品| 99久久国产免费福利| 久久久久免费精品国产| 国产精品美女久久久网AV| 日韩人妻无码一区二区三区久久99 | 久久人人爽人人精品视频| 中文字幕久久久久人妻| 国产亚洲色婷婷久久99精品91| 99久久免费国产精品特黄| 国产激情久久久久影院| 无码久久精品国产亚洲Av影片 | 欧美伊人久久大香线蕉综合 | 久久久黄片| 久久91精品久久91综合| 亚洲精品tv久久久久| 99久久国产免费福利| 精品999久久久久久中文字幕 | 色综合久久中文综合网| 色欲久久久天天天综合网| 色偷偷91久久综合噜噜噜噜| 青草影院天堂男人久久| 1000部精品久久久久久久久| 亚洲AV无一区二区三区久久| 亚洲国产视频久久| 亚洲精品NV久久久久久久久久 | 亚洲伊人久久成综合人影院 | 国产亚洲精品自在久久| 色偷偷88888欧美精品久久久| 亚洲午夜久久久久久久久久| 中文字幕精品久久| 无码任你躁久久久久久老妇App| 久久精品国产亚洲AV不卡| 久久精品国产只有精品66| 久久人人超碰精品CAOPOREN| 亚洲а∨天堂久久精品| 久久婷婷国产剧情内射白浆|