当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > ASP.NET教程:多个Set排列算法

ASP.NET
many-to-many多对多映射
.NETRemotingChannelListener
转载李建忠老师的一篇文章
原创ColorComboBox控件
用IDisposable接口释放.NET资源
c#v2.0 扩展特性 翻译1
XPath中如何比较不同类型的对象
用哈希表搜索对象
C#陷阱int i = 10; i += i++; i =
Make a window that pops up from taskbar
获取网站返回的头部信息
自己动手写屏保
在DataGrid中添加Radio单选按钮列
实现性能目标的几种方法
增强.NETFramework中线程的功能
ASP.NET 2.0,写无限级下拉菜单不再难
book_dotnet
用.NET武装你的头脑
准备你的发布阶段
移植到.NET

ASP.NET教程:多个Set排列算法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-28   浏览: 292 ::
收藏到网摘: n/a

using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
public class Test{
public static void Main(string [] args){
    string CheckDefault="A,B,C;D,E;G,F,J";
    string[] Lists=CheckDefault.Split(';');
    int MAXResult=1;
    int MAXColum=Lists.Length;
    List<string[]> c=new List<string[]>(MAXColum);
    for(int i=0;i< MAXColum;i++){
        c.Add(Lists[i].Split(','));
        MAXResult*=c[i].Length;
    }
    int[] k=new int[MAXColum];
    for(int i=0;i<MAXResult;i++){
        for(int j=0;j<MAXColum;j++){
            Console.Write( c[j][k[j]]+(j==MAXColum-1?"\r\n":""));
        }
        AddOne(c,ref k);
    }
    Console.WriteLine("总数是{0}",MAXResult);
}
public static void AddOne(List<string[]> c,ref int[] k){
    int zoomCol=k.Length-1;
    while(zoomCol>0 &&  k[zoomCol]+1 == c[zoomCol].Length){
        k[zoomCol]=0;
        zoomCol--;
    }
    k[zoomCol]+=1;
}
}