• <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年7月>
            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 鷹擊長空 閱讀(325) 評論(0)  編輯 收藏 引用
            久久久久无码中| 久久无码人妻精品一区二区三区| 伊人久久无码精品中文字幕| 国产精品亚洲综合久久| 97久久国产综合精品女不卡| 亚洲人成网亚洲欧洲无码久久| 久久久久国产精品麻豆AR影院 | 久久露脸国产精品| 久久人人爽人人爽人人片av麻烦 | 91久久九九无码成人网站| 久久露脸国产精品| 色综合久久久久久久久五月| 欧美一区二区精品久久| 久久综合给合久久狠狠狠97色 | 久久免费高清视频| 狠狠色婷婷久久一区二区| 777久久精品一区二区三区无码| 少妇熟女久久综合网色欲| 青青草原综合久久大伊人精品| 久久亚洲sm情趣捆绑调教| 国产成人精品久久亚洲高清不卡| 麻豆AV一区二区三区久久| 久久久久九九精品影院| www性久久久com| 久久久久久国产精品免费无码| 亚洲色婷婷综合久久| 无码乱码观看精品久久| 久久精品这里只有精99品| 91精品国产色综合久久| 久久国产精品无码一区二区三区| 青青草国产97免久久费观看| 99久久精品无码一区二区毛片| 久久这里只有精品18| 亚洲色大成网站www久久九| 少妇人妻综合久久中文字幕| 久久人人爽人人精品视频 | 国产成人精品综合久久久久| 亚洲欧洲中文日韩久久AV乱码| 久久精品无码一区二区三区免费| 久久福利青草精品资源站免费| 久久国产成人精品国产成人亚洲|