class Program
{
static void Main(string[] args)
{
string[][] elements = new string[][]{
new string[]{"1a","1b"},
new string[]{"2a"},
new string[]{"3a","3b"},
new string[]{"4a"},
new string[]{"5a"},
new string[]{"6a"},
new string[]{"7a", "7b"},
};
//算出组合总个数
int total = 1;
for (int x = 0; x < elements.Length; x++)
total *= elements[x].Length;
//创建存放组合的临时数组
string[] row = new string[elements.Length];
//编历生成组合
for (int i = 0; i < total; i++)
{
int current = 0, next = i;
for (int j = 0; j < row.Length; j++)
{
current = next;
int max = elements[j].Length;
if (current >= max) //当下标溢出时进位
{
next = current / max;
current = current % max;
}
else
{
next = 0;
}
row[j] = elements[j][current];
}
Console.WriteLine(string.Join("-", row));
}
Console.Read();
}
}