指数0可以移至2,18,19
指数1可以移至5,17,18
等。
我试图在for循环中初始化数组如下:
for (int i = 0; i < ROOMS; i++)
{
//?
}
但我不知道如何启动数组,I.e:
arr[0] = new Indexes(2,18,19);//The indexes that we can moved from index 0
arr[1] = new Indexes(5,17,18);//The indexes that we can moved from index 1
arr[2] = new Indexes(0,4,17);//The indexes that we can moved from index 2
我怎么能在for循环中做到这一点?
谢谢!
答案 0 :(得分:2)
第k个节点的邻居的通用公式:
19 - k;
(k + t) mod 20;
(k - t + 20) mod 20;
,其中
t = 2 + 2 * (k and 1) //2 for even, 4 for odd