• <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 閱讀(1258) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Data Structures & Algorithms
            By JonsenElizee
            久久久无码精品亚洲日韩按摩| 久久99热只有频精品8| 亚洲国产成人久久综合一区77| 999久久久免费国产精品播放| 成人a毛片久久免费播放| 日韩人妻无码一区二区三区久久99 | 久久综合香蕉国产蜜臀AV| 91久久精品91久久性色| 亚洲国产二区三区久久| 久久午夜无码鲁丝片秋霞 | 国产亚洲欧美精品久久久| 精品久久久无码中文字幕| 色婷婷久久综合中文久久蜜桃av| 久久被窝电影亚洲爽爽爽| 综合网日日天干夜夜久久| 91精品日韩人妻无码久久不卡| 人妻无码精品久久亚瑟影视 | 国产成人无码精品久久久久免费| 91亚洲国产成人久久精品| 久久性生大片免费观看性| 久久精品99久久香蕉国产色戒 | 久久久久亚洲精品无码网址| 国产成人综合久久综合| 久久天天躁狠狠躁夜夜2020一| 国产成人综合久久综合| 久久精品www人人爽人人| 人妻无码精品久久亚瑟影视| 99热热久久这里只有精品68| 99久久国语露脸精品国产| 久久久噜噜噜久久熟女AA片| 亚洲伊人久久成综合人影院 | AA级片免费看视频久久| 久久线看观看精品香蕉国产| 午夜天堂av天堂久久久| 中文国产成人精品久久不卡| 伊人久久大香线蕉无码麻豆| 久久天天躁狠狠躁夜夜不卡| 国产真实乱对白精彩久久| 久久99精品国产99久久6| 伊人色综合久久| 久久久久99精品成人片牛牛影视|