• <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 閱讀(1259) 評論(0)  編輯 收藏 引用 所屬分類: Data Structures & Algorithms
            By JonsenElizee
            久久婷婷人人澡人人| 国内精品伊人久久久久妇| 久久九九亚洲精品| 国产精品欧美亚洲韩国日本久久| 久久精品国产清自在天天线| 久久夜色精品国产www| 天天躁日日躁狠狠久久| 人人狠狠综合久久亚洲婷婷| 欧美午夜A∨大片久久 | 久久国产色AV免费观看| 精品一久久香蕉国产线看播放| 久久精品国产亚洲AV香蕉| 99久久精品国产高清一区二区 | 国产69精品久久久久9999APGF| 久久夜色精品国产网站| 久久婷婷五月综合97色直播| 久久精品无码午夜福利理论片| 免费一级欧美大片久久网| 国产三级久久久精品麻豆三级| 亚洲七七久久精品中文国产| 99久久精品国产一区二区蜜芽| 久久精品人人做人人爽97| 久久成人国产精品免费软件| 无码任你躁久久久久久| 欧美精品一本久久男人的天堂| 天堂久久天堂AV色综合| 久久精品国产乱子伦| 久久亚洲高清综合| 国内精品伊人久久久久影院对白 | 狠狠色丁香婷综合久久| 中文国产成人精品久久不卡| 日韩影院久久| 久久久久无码精品| 久久人人爽人人精品视频| 99热成人精品免费久久| 久久综合久久综合久久| 69久久精品无码一区二区| 国产91色综合久久免费| 日本免费久久久久久久网站| 国产精品久久久久9999| 秋霞久久国产精品电影院|