标签:count 算法 调用 bre [] trim for str ++
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);
标签:count 算法 调用 bre [] trim for str ++
原文地址:http://www.cnblogs.com/shengfan/p/7735548.html