我在本mainArray(動態生成的):如何在獨特陣列動態拆分陣列
static void Main()
{
var n = 3;
var k = 2;
var a = n * k;
var mainArray = new int[a];
var index = 0;
for (var i = 0; i < n; i++)
{
for (var j = 0; j < k; j++)
{
mainArray[index] = i;
index++;
}
}
//=> mainArray=[0,0,1,1,2,2]
// How to split this array in 3 uniq arrays, like:
//array1=[0,1]
//array2=[1,2]
//array3=[0,2]
Console.WriteLine(String.Join(",", mainArray));
Console.ReadLine();
}
mainArray = [0,0,1,1,2,2]
如何分割這陣列中的3個uniq的陣列,如:
ARRAY1 = [0,1]
數組2 = [1,2]
ARRAY3 = [0,2]
我該怎麼辦?
[0,0] [1,1],[2,2] =不uniq的; [0,1],[0,1] [2,2] =不是uniq; ,唯一的可能性是我的問題; –