高分求助 !!数组组合问题
数组1: 1,2,3,4,5,6数组2: 3,4,5,6,7,8
========================
数组5: 2,3,4,5,6,7
数组6: 3,4,5,6,7,8
数组7: 4,5,6,7,8,9
数组8: 3,4,5,6,7,12
如何能让 数组1,2 和数组 5,6,7,8 依次组合
比如: 数组1 先和数组5 组合 结果 1,2,3,4,5,6 2,3,4,5,6,7
数组1 先和数组6 组合 结果 1,2,3,4,5,6 3,4,5,6,7,8
数组1 先和数组7 。。。。。。。。。。。
数组1 先和数组8 。。。。。。。。。。。
然后:
数组2 先和数组5 组合 结果 3,4,5,6,7,8 2,3,4,5,6,7
数组2 先和数组6 组合 结果 3,4,5,6,7,8 3,4,5,6,7,8
数组2 先和数组7 。。。。。。。。。。。
数组2 先和数组8 。。。。。。。。。。。
--------------------编程问答-------------------- http://www.cnblogs.com/rogerwei/archive/2010/11/18/1880336.html
就是排列组合吧 --------------------编程问答-------------------- 上面数组有很多组 --------------------编程问答-------------------- 数组操作可以看二楼版猪发的连接
然后你说的依次组合,那纯属逻辑问题,自己想怎么方便怎么做吧
如果有固定名字就循环结合,如果没有就老老实实一个一个加
比如说1,2数组不管,5-8数组分别命名为 arry5-arry8
然后自己循环操作
至于结果怎么存也是自己随便想怎么存就怎么存的事 --------------------编程问答-------------------- 循环一下就行了
--------------------编程问答-------------------- 这个可行 但是数据有很多组 全都写上困难
List<int[]> list1 = new List<int[]>() { new int[] { 1, 2, 3, 4, 5, 6 }, new int[] { 3, 4, 5, 6, 7, 8 }, new int[] { 9, 10, 11, 12, 13, 14 } };
List<int[]> list2 = new List<int[]>() { new int[] { 2, 3, 4, 5, 6, 7 }, new int[] { 3, 4, 5, 6, 7, 8 }, new int[] { 4, 5, 6, 7, 8, 9 }, new int[] { 3, 4, 5, 6, 7, 12 } };
List<List<int[]>> list3 = new List<List<int[]>>();
foreach (var l1 in list1)
{
list3.Add(list2.Select(x => l1.Concat(x).ToArray()).ToList());
}
int p = 0;
foreach (var l3 in list3)
{
foreach (var l4 in l3)
{
p++;
Console.WriteLine(String.Join(",", l4.ToArray()));
if (p == 4)
{
Console.WriteLine("=========================================");
p = 0;
}
}
}
另外 数组是从 别的地方读过来的 定义一个大数组 里面装 这些数组 怎么定义 --------------------编程问答--------------------
List<T>啊,T可以定义成数组
补充:.NET技术 , ASP.NET