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

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

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

    隨筆-12  評論-0  文章-1  trackbacks-0
    求從n個不重復數(shù)中取出m個數(shù)的所有組合(排列):
        private static LinkedList<Integer> result = new LinkedList<Integer>();
        
        
    private static long resultCount = 0;

        
    private static void combine(int[] source, int m, int start) {

            
    if (result.size() == m) {
                resultCount
    ++;
                printResult(result);
                
    return;
                
            }
            
    for (int i = start; i < source.length; i++) {
                result.add(source[i]);
                combine(source, m, i 
    + 1);
                result.removeLast();
            }
        }
        
        
    private static void permutate(int[] source, int m) {
            
    if (result.size() == m) {
                resultCount
    ++;
                printResult(result);
                
    return;
            }
            
    for (int i = 0; i < source.length; i++) {
                
    if (result.contains(source[i])) {
                    
    continue;
                }
                result.add(source[i]);
                permutate(source, m);
                result.removeLast();
            }
        }
        
        
    private static void printResult(List<Integer> result) {
            Iterator
    <Integer> it = result.iterator();
            
    while (it.hasNext()) {
                System.out.print(it.next() 
    + "  ");
            }
            
            System.out.println();

        }

    調(diào)用代碼
            int[] source = new int[10];
            
    for (int i = 0; i < source.length; i++) {
                source[i] 
    = i + 1;
            }
            
            combine(source, 
    60);

            //permutate(source, 2);
            
            System.out.println(
    "total number is " + resultCount);

    posted on 2009-09-13 22:29 Sam Zheng 閱讀(390) 評論(0)  編輯  收藏

    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導航:
     
    主站蜘蛛池模板: 亚洲小说区图片区另类春色| 成人免费在线观看网站| 亚洲精品美女久久久久99小说| 亚洲国产精品免费观看| 国产曰批免费视频播放免费s| 亚洲大片在线观看| 久久免费看黄a级毛片| 亚洲日韩国产精品无码av| 91在线老王精品免费播放| 亚洲免费在线视频观看| 国产va精品免费观看| 特黄aa级毛片免费视频播放| 大学生a级毛片免费观看| 亚洲AV无码专区在线观看成人| a级片免费在线播放| 亚洲成AV人在线播放无码| 老汉精品免费AV在线播放| 亚洲精品在线电影| 一级毛片免费播放男男| 综合亚洲伊人午夜网 | 久久久www成人免费毛片| 欧洲 亚洲 国产图片综合| 免费国产成人午夜电影| 国产精品无码永久免费888| 亚洲成AV人片在线观看| 永久免费视频网站在线观看| 中文字幕 亚洲 有码 在线| 免费午夜爽爽爽WWW视频十八禁 | 亚洲成网777777国产精品| 日韩在线视频免费| 午夜亚洲www湿好大| 成人免费无码大片A毛片抽搐色欲 成人免费无码大片a毛片 | 成年人免费视频观看| 特级毛片全部免费播放a一级| 亚洲国产精品SSS在线观看AV| 成年网站免费视频A在线双飞| 免费一级做a爰片久久毛片潮| A在线观看免费网站大全| 黄色网址免费在线| 久久久久亚洲AV无码网站| 韩国二级毛片免费播放|