• <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)

            隨筆檔案

            文章檔案

            網(wǎng)頁(yè)收藏

            搜索

            •  

            最新評(píng)論

            閱讀排行榜

            評(pí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 鷹擊長(zhǎng)空 閱讀(324) 評(píng)論(0)  編輯 收藏 引用

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            久久精品视频91| 9999国产精品欧美久久久久久| 久久精品无码一区二区日韩AV| 精品午夜久久福利大片| 久久笫一福利免费导航| 国产欧美久久久精品| 四虎国产精品免费久久5151| 久久九九久精品国产免费直播| 美女久久久久久| 国产精品成人99久久久久 | 一级做a爰片久久毛片看看| 国产一级持黄大片99久久 | 一本久久a久久精品亚洲| 精品久久久久久久久久中文字幕| 久久精品国产99国产精偷| 欧美精品丝袜久久久中文字幕| 久久久久人妻一区精品性色av| 欧美国产成人久久精品| 一本一道久久a久久精品综合| 人妻无码久久一区二区三区免费 | 久久久久四虎国产精品| 久久伊人五月丁香狠狠色| 亚洲伊人久久大香线蕉苏妲己| 国产69精品久久久久APP下载 | 国内精品久久久久久野外| 2021国内久久精品| 国内精品伊人久久久久影院对白| 久久久免费精品re6| A级毛片无码久久精品免费| 久久久久国产| 久久久久无码中| 久久久久亚洲精品天堂久久久久久 | 66精品综合久久久久久久| 国产精品18久久久久久vr| 青青青青久久精品国产| 亚洲国产欧美国产综合久久| 精品综合久久久久久97超人| 久久99国产乱子伦精品免费| 精品久久国产一区二区三区香蕉| 久久香蕉综合色一综合色88| 亚洲精品国产成人99久久|