• <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 閱讀(1260) 評論(0)  編輯 收藏 引用 所屬分類: Data Structures & Algorithms
            By JonsenElizee
            亚洲国产香蕉人人爽成AV片久久 | 久久精品国产乱子伦| 亚洲v国产v天堂a无码久久| 一本久道久久综合狠狠躁AV| 精品国产日韩久久亚洲| 精品无码久久久久久午夜| 亚洲天堂久久久| 99久久99久久| 久久精品人成免费| 久久久久久国产精品免费无码| 欧美久久综合性欧美| 欧美精品一区二区精品久久| 亚洲精品无码久久不卡| 精品久久久久久久无码 | 欧美精品福利视频一区二区三区久久久精品 | 精品国产一区二区三区久久久狼 | 伊人久久大香线蕉亚洲| 久久精品中文字幕有码| 91精品国产91热久久久久福利| 国产精品久久免费| 久久综合亚洲色一区二区三区| 国内精品欧美久久精品| 国内精品久久久久影院网站| 亚洲va国产va天堂va久久| 色综合久久久久久久久五月 | 亚洲午夜久久久久久久久电影网| 精品久久久无码中文字幕| 国产精品免费看久久久| 中文精品久久久久人妻不卡| 久久免费国产精品| 久久精品无码av| 久久99精品久久久久久齐齐| 亚洲伊人久久大香线蕉苏妲己| 国产∨亚洲V天堂无码久久久| 久久久精品2019免费观看| 亚洲精品乱码久久久久久中文字幕 | 亚洲国产另类久久久精品| 狠狠色噜噜色狠狠狠综合久久| 99精品国产99久久久久久97| 久久人妻少妇嫩草AV蜜桃| 久久久久国产精品人妻|