class Program
{
static void Main(string[] args)
{
string[] str1 = { "a", "b" };
string[] str2 = { "1" };
string[] str3 = { "一", "二", "三" };
string[] str 4 = { "4", "5", "6" };
string[] str5 = { "7", "8"};
string[] str6 = { "9", "+", "-" };
List<string[]> list = newList<string[]>();
list.Add(str1);
list.Add(str2);
list.Add(str3);
list.Add(str4);
list.Add(str5);
list.Add(str6);
List<string> result = newList<string>();
Descartes(list, 0, result, string.Empty);
foreach (var item in result)
{
Console.WriteLine(item);
}
}
private static stringDescartes(List<string[]> list, intcount, List<string> result, stringdata)
{
string temp = data;
//获取当前数组
string[] astr = list[count];
//循环当前数组
foreach (var item in astr)
{
if (count + 1 < list.Count)
{
temp += Descartes(list, count + 1, result, data + item);
}
else
{
result.Add(data + item);
}
}
return temp;
}
}