• <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)  編輯 收藏 引用
            久久只有这里有精品4| 久久免费视频网站| 久久只有这精品99| 成人国内精品久久久久一区| 久久水蜜桃亚洲av无码精品麻豆| 伊人久久大香线焦综合四虎| 久久受www免费人成_看片中文| 久久99国产精品尤物| 色8激情欧美成人久久综合电| 亚洲国产精品高清久久久| 国产亚洲精久久久久久无码AV| 国内精品伊人久久久久777| 久久青草国产精品一区| 亚洲av日韩精品久久久久久a| 久久久久黑人强伦姧人妻| 99精品国产在热久久无毒不卡| 少妇久久久久久被弄到高潮| 国产精品福利一区二区久久| 久久久久久精品成人免费图片| 久久99精品久久久久久野外| 国产精品禁18久久久夂久| 久久亚洲精品无码VA大香大香 | 久久精品无码一区二区app| 久久精品国产亚洲AV无码娇色 | 久久AⅤ人妻少妇嫩草影院| 久久国产乱子伦免费精品| 精品久久人人爽天天玩人人妻| 久久久中文字幕日本| 久久久精品人妻无码专区不卡| 国产高潮国产高潮久久久91 | 99久久国产热无码精品免费久久久久| 亚洲精品国精品久久99热一| 欧美午夜精品久久久久久浪潮| 成人午夜精品久久久久久久小说 | 精品熟女少妇aⅴ免费久久| 99久久精品免费看国产一区二区三区| 91精品国产色综合久久| 成人妇女免费播放久久久| 韩国三级大全久久网站| 久久国产精品成人免费| 999久久久免费国产精品播放|