<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    不重復(fù)的排列組合示例

    昨天看到個(gè)帖子, 然后想了想寫出一段程序來.  有空該補(bǔ)補(bǔ)排列組合的知識(shí)了.

     1 /**
     2  * 各字符不重復(fù)的組合, 組合數(shù)小于等于最大可能性(否則就重復(fù)了).
     3  * 
     4  * @author scud(飛云)
     5  */
     6 public class ShortCombineTest
     7 {
     8     static int count = 0;
     9 
    10     public static void main(String[] args)
    11     {
    12         String s = "123456"//all items content
    13         int howmany = 3//how many object
    14 
    15         char[] c = s.toCharArray();
    16         char[] dest = new char[howmany];
    17 
    18         combine(c, dest, howmany, s.length(), 0);
    19 
    20         System.out.println("max combine:" + count);
    21     }
    22 
    23     public static void combine(char[] array, char[] dest, int howmany, int maxitem, int index)
    24     {
    25         //break & end
    26         if (index == howmany)
    27         {
    28             System.out.println(dest);
    29             count++;
    30             return;
    31         }
    32 
    33         while(array.length>0)
    34         {
    35             dest[index] = array[0];
    36             char[] nextarray = getLeftChar(array, 0);
    37             array = nextarray;
    38             combine(nextarray, dest, howmany, maxitem, index + 1);
    39         }
    40     }
    41 
    42     public static char[] getLeftChar(char[] c, int index)
    43     {
    44         char[] left = new char[c.length - 1];
    45 
    46         for (int i = 0, j = 0; i < c.length; i++)
    47         {
    48             if (i != index)
    49             {
    50                 left[j] = c[i];
    51                 j++;
    52             }
    53         }
    54 
    55         return left;
    56     }
    57 
    58 
    59 }
    60 


    posted on 2010-07-29 09:55 Scud(飛云小俠) 閱讀(440) 評(píng)論(0)  編輯  收藏 所屬分類: Java

    <2010年7月>
    27282930123
    45678910
    11121314151617
    18192021222324
    25262728293031
    1234567

    導(dǎo)航

    統(tǒng)計(jì)

    公告

    文章發(fā)布許可
    創(chuàng)造共用協(xié)議:署名,非商業(yè),保持一致

    我的郵件
    cnscud # gmail


    常用鏈接

    留言簿(15)

    隨筆分類(113)

    隨筆檔案(103)

    相冊(cè)

    友情鏈接

    技術(shù)網(wǎng)站

    搜索

    積分與排名

    最新評(píng)論

    閱讀排行榜

    評(píng)論排行榜

    主站蜘蛛池模板: 亚洲国产精品第一区二区| 国产精品99精品久久免费| 四虎在线成人免费网站| 国产成人精品无码免费看 | 91嫩草亚洲精品| 最近最好最新2019中文字幕免费| 国产亚洲精品美女久久久久| 香港经典a毛片免费观看看| 中文字幕视频在线免费观看| 国产aⅴ无码专区亚洲av麻豆| 水蜜桃亚洲一二三四在线| 久久夜色精品国产噜噜亚洲a| 久久精品网站免费观看| 亚洲色欲啪啪久久WWW综合网| 哒哒哒免费视频观看在线www | 亚洲综合综合在线| 黄网站色在线视频免费观看| 亚洲无吗在线视频| 免费观看大片毛片| 永久免费精品影视网站| 亚洲AV无码久久精品蜜桃| 8888四色奇米在线观看免费看| 亚洲尹人香蕉网在线视颅| AV片在线观看免费| 一区二区三区免费在线视频 | 亚洲AV无码专区在线电影成人| 无码国产精品一区二区免费模式 | 视频免费1区二区三区| 亚洲国产精品无码久久SM| 免费人妻精品一区二区三区| 国产成人免费高清激情明星| 亚洲中文久久精品无码1| 国产精品无码一区二区三区免费| 一二三四在线观看免费中文在线观看| 亚洲亚洲人成综合网络| 免费一级毛片在线播放放视频 | 丰满少妇作爱视频免费观看| 国产美女精品久久久久久久免费 | 污污视频网站免费观看| 国产亚洲欧洲精品| 日韩电影免费在线观看网站|