private string[] bianli(List<string[]> al)
{
if (al.Count == 0)
return null;
int size = 1;
for (int i = 0; i < al.Count; i++)
{
size = size * al[i].Length;
}
string[] str = new string[size];
for (int j = 0; j < size; j++)
{
for (int m = 0; m < al.Count; m++)
{
str[j] = str[j] + al[m][(j * jisuan(al, m) / size) % al[m].Length] + ” “;
}
str[j] = str[j].Trim(\’ \’);
}
return str;
}
private int jisuan(List<string[]> al, int m)
{
int result = 1;
for (int i = 0; i < al.Count; i++)
{
if (i <= m)
result = result * al[i].Length;
else break;
}
return result;
}

 

调用方式:

string[] a = new string[] { “1”, “2”, “3” };
string[] b = new string[] { “2”, “3”, “4”, “5” };
string[] c = new string[] { “2”, “3”, “9” };

List<string[]> al = new List<string[]>(){ a,b,c };

string[] mmm= bianli(al);

版权声明:本文为shengfan原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/shengfan/p/7735548.html