Asp. NET Tutorial: Multiple set permutation algorithms
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 ("Total is {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;
}
}