• <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
            <2025年6月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            293012345

            常用鏈接

            留言簿(2)

            隨筆檔案

            文章檔案

            網(wǎng)頁收藏

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            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)  編輯 收藏 引用
            99久久国语露脸精品国产| 久久se精品一区二区影院 | 国产精品久久久久一区二区三区 | 最新久久免费视频| 亚洲午夜久久久久妓女影院| 色婷婷久久综合中文久久蜜桃av | 久久久久女教师免费一区| 亚洲午夜久久久久久噜噜噜| 色综合久久无码中文字幕| 久久97久久97精品免视看秋霞| 久久天天躁狠狠躁夜夜2020| 久久精品一本到99热免费| 精品久久亚洲中文无码| 91麻豆精品国产91久久久久久| 成人久久免费网站| AV色综合久久天堂AV色综合在 | 中文国产成人精品久久不卡| 亚洲精品高清久久| 色诱久久久久综合网ywww | 大蕉久久伊人中文字幕| 久久久久久久久久久| 伊人久久综在合线亚洲2019| 亚洲国产综合久久天堂| 超级碰久久免费公开视频| 漂亮人妻被黑人久久精品| 亚洲国产成人乱码精品女人久久久不卡 | 久久久久无码中| 久久福利青草精品资源站免费 | 久久免费精品视频| 久久福利青草精品资源站| 亚洲AV乱码久久精品蜜桃| 日本久久中文字幕| 久久午夜夜伦鲁鲁片免费无码影视| 麻豆久久| 久久亚洲天堂| 婷婷久久精品国产| 久久久久亚洲av成人无码电影| 久久精品国产精品国产精品污| 久久综合精品国产二区无码| 亚洲精品国产美女久久久| 亚洲AV日韩AV天堂久久|