<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)站導航:
     
    主站蜘蛛池模板: 国产激情免费视频在线观看 | 91久久成人免费| 亚洲熟妇无码乱子AV电影| 男女猛烈激情xx00免费视频| 免费一级毛片女人图片| 男男gay做爽爽免费视频| 亚洲国产激情一区二区三区| 污视频网站免费观看| 亚洲国产一区二区视频网站| 成人a毛片视频免费看| 国产亚洲情侣一区二区无| 一区二区三区免费精品视频| 亚洲色成人中文字幕网站 | www.xxxx.com日本免费| 国产亚洲免费的视频看| 久草免费福利资源站| 久久亚洲AV成人无码| 国产香蕉九九久久精品免费| 亚洲乱码无人区卡1卡2卡3| 免费看男女下面日出水视频| 免费毛片毛片网址| 亚洲综合图色40p| 外国成人网在线观看免费视频| 99久久亚洲精品无码毛片| 毛片免费在线观看网址| 青草青草视频2免费观看| 国产亚洲色婷婷久久99精品| 84pao国产成视频免费播放| 亚洲小说图区综合在线| 亚洲AV中文无码乱人伦在线视色| 中文字幕av免费专区| 亚洲第一精品电影网| 国产福利免费在线观看| 国精产品一区一区三区免费视频 | 久久99国产亚洲精品观看| 久久久高清免费视频| 一级毛片大全免费播放下载| 亚洲AV成人片色在线观看高潮| 拍拍拍又黄又爽无挡视频免费| 一区二区三区免费视频观看| 亚洲日产2021三区在线|