• <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年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(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 鷹擊長空 閱讀(317) 評論(0)  編輯 收藏 引用
            91精品国产91久久| 久久午夜无码鲁丝片| 久久久综合香蕉尹人综合网| 久久久艹| 91精品国产高清久久久久久io| 久久久青草久久久青草| 久久只有这精品99| 久久福利青草精品资源站免费| 国产精品欧美久久久久无广告| 丁香色欲久久久久久综合网| 国产福利电影一区二区三区,免费久久久久久久精 | 久久se精品一区精品二区国产| 久久无码一区二区三区少妇| 中文字幕无码免费久久| 99久久精品无码一区二区毛片| 99精品国产99久久久久久97| 91亚洲国产成人久久精品| 婷婷五月深深久久精品| 亚洲国产精品无码久久青草| 伊人热人久久中文字幕| 久久棈精品久久久久久噜噜| 伊人久久大香线蕉成人| 久久亚洲欧美日本精品| 久久九九精品99国产精品| 伊人久久五月天| 欧美日韩精品久久久久| 国产精品欧美久久久久无广告 | 性高湖久久久久久久久AAAAA | 国产激情久久久久影院老熟女免费| 精品伊人久久大线蕉色首页| 久久这里只有精品视频99| 久久国产影院| 久久影视国产亚洲| 亚洲精品视频久久久| 久久人人爽人人爽人人av东京热 | 亚洲精品无码久久久久sm| 综合网日日天干夜夜久久 | 久久乐国产综合亚洲精品| 久久人人青草97香蕉| 久久久久久综合网天天| 亚洲午夜久久久久妓女影院|