• <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>
            隨筆 - 42  文章 - 3  trackbacks - 0
            <2012年5月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            常用鏈接

            留言簿(2)

            隨筆檔案

            文章檔案

            網頁收藏

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            print all permutations of a given string. A permutation, also called an “arrangement number” or “order,” is a rearrangement of the elements of an ordered list S into a one-to-one correspondence with S itself. A string of length n has n! permutation.

            # include <stdio.h>
              
            /* Function to swap values at two pointers */
            void swap (char *x, char *y)
            {
                char temp;
                temp = *x;
                *x = *y;
                *y = temp;
            }
               
            /* Function to print permutations of string
               This function takes three parameters:
               1. String
               2. Starting index of the string
               3. Ending index of the string. */
            void permute(char *a, int i, int n) 
            {
               int j; 
               if (i == n)
                 printf("%s\n", a);
               else
               {
                    for (j = i; j <= n; j++)
                   {
                      swap((a+i), (a+j));
                      permute(a, i+1, n);
                      swap((a+i), (a+j)); //backtrack
                   }
               }
              
            /* Driver program to test above functions */
            int main()
            {
               char a[] = "ABC";  
               permute(a, 0, 2);
               getchar();
               return 0;
            }

            2. find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.
            #include<stdio.h>
            int maxSubArraySum(int a[], int size)
            {
               int max_so_far = 0, max_ending_here = 0;
               int i;
               for(i = 0; i < size; i++)
               {
                 max_ending_here = max_ending_here + a[i];
                 if(max_ending_here < 0)
                    max_ending_here = 0;
                 if(max_so_far < max_ending_here)
                    max_so_far = max_ending_here;
                }
                return max_so_far;
             
            /*Driver program to test maxSubArraySum*/
            int main()
            {
               int a[] = {-2, -3, 4, -1, -2, 1, 5, -3};
               int max_sum = maxSubArraySum(a, 8);
               printf("Maximum contiguous sum is %d\n", max_sum);
               getchar();
               return 0;
            }

            posted on 2012-07-05 17:51 鷹擊長空 閱讀(322) 評論(0)  編輯 收藏 引用
            精品综合久久久久久97| 国产精品内射久久久久欢欢| 一本色综合网久久| 久久天堂AV综合合色蜜桃网| 91精品国产9l久久久久| 久久影院亚洲一区| 精品熟女少妇a∨免费久久| 久久99精品九九九久久婷婷| 性色欲网站人妻丰满中文久久不卡| 久久青青草原综合伊人| 久久亚洲国产精品成人AV秋霞 | 婷婷久久香蕉五月综合加勒比| 精品国产乱码久久久久久郑州公司 | 99麻豆久久久国产精品免费 | 国产亚洲精久久久久久无码77777 国产亚洲精品久久久久秋霞 | 久久黄视频| 国产亚洲欧美成人久久片| 亚洲人成无码久久电影网站| 久久国产精品久久| 久久精品午夜一区二区福利| 久久午夜福利电影| 93精91精品国产综合久久香蕉 | 97久久国产露脸精品国产| 国产福利电影一区二区三区,免费久久久久久久精 | 国产精品久久国产精麻豆99网站| 日日狠狠久久偷偷色综合96蜜桃| 亚洲伊人久久大香线蕉苏妲己 | 久久精品国产WWW456C0M| 久久精品国产第一区二区三区| 热99RE久久精品这里都是精品免费| 久久精品国产亚洲Aⅴ香蕉| 精品久久久久久久无码| 久久天堂AV综合合色蜜桃网 | 色欲综合久久中文字幕网| 久久亚洲中文字幕精品一区四| 国产精品久久久久乳精品爆| 国产成人精品久久免费动漫| 精品999久久久久久中文字幕| 精品久久无码中文字幕| 国产成人精品白浆久久69| 久久久久亚洲精品天堂|