• <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年8月>
            272829303112
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            常用鏈接

            留言簿(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 鷹擊長空 閱讀(333) 評論(0)  編輯 收藏 引用
            亚洲精品tv久久久久久久久 | 亚洲国产精品嫩草影院久久| 久久亚洲av无码精品浪潮| 久久婷婷午色综合夜啪| 97久久综合精品久久久综合| 久久性生大片免费观看性| 国产精品久久久福利| 国内精品伊人久久久久妇| 天天久久狠狠色综合| 一本久道久久综合狠狠爱| 色综合久久中文字幕综合网| 久久国产成人精品麻豆| 亚洲精品国产美女久久久| 久久婷婷色香五月综合激情| 久久综合九色综合久99| 久久久久亚洲av无码专区导航| 无码人妻久久一区二区三区蜜桃| 久久国产乱子伦精品免费强| 亚洲AV无码久久寂寞少妇| 久久婷婷色香五月综合激情| 久久九色综合九色99伊人| 亚洲嫩草影院久久精品| 久久精品男人影院| 久久亚洲精品成人av无码网站| 香港aa三级久久三级老师2021国产三级精品三级在 | 久久精品免费观看| 狠狠色婷婷久久一区二区三区| 久久无码中文字幕东京热| 日韩美女18网站久久精品| 久久国产免费| 久久受www免费人成_看片中文| 久久夜色精品国产| 日本久久久久久久久久| 久久久久99精品成人片| 一级做a爰片久久毛片人呢| 7国产欧美日韩综合天堂中文久久久久| 欧洲国产伦久久久久久久| 久久精品国产91久久麻豆自制| 狠狠色丁香婷婷综合久久来| 国产精品久久久福利| 91久久精品国产成人久久|