我正试图在日食中创建一个记忆比赛。我目前已经创建并可以使用4x4电路板。如何创建6 x 6板。
具体地说,我应该将s <= 20更改为6x6
//shuffle the cards
public static int[][] shuf() {
int start[] = {1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8};
int cards[][] = new int[4][4];
Random ran = new Random();
int tmp, i;
for (int s = 0; s <= 20; s++) {
for (int x = 0; x < 16; x++) //randomize the card placements
{
i = ran.nextInt(100000) % 15;
tmp = start[x];
start[x] = start[i];
start[i] = tmp;
}
}
i = 0;
for (int r = 0; r < 4; r++) // put values in cards here
{
for (int c = 0; c < 4; c++) {
cards[r][c] = start[i];
i = i + 1;
}
}
return cards;
}
}
答案 0 :(得分:0)
在代码中,您可以引用多个地方
看看这些并进行更新,即
int cards[][] = new int[6][6];
for
循环:r < 6;
和c < 6;
要坚持当前的方法,还需要将start[]
的大小增加到36
。