.... 晕 啊。。。 加分啊
String ap = "abcdefghijklmnop";
String[] aps = ap.split(""); // 处理成字符串数组
String[][] ap88 = new String[8][8];
int index = 0;
//以下循环赋值
for (String[] strings : ap88) {
if(index % 2 == 0)
System.arraycopy(aps, 1, strings, 0, 8);
else
System.arraycopy(aps, 9, strings, 0, 8);
index += 1;
}
Random random = new Random(System.currentTimeMillis());
//默认 交换64次 因为是8*8 则 xy可以互相对调 为了更加随机 交换2次
// 若 x=1 y=2 则 [1][2] [6][5] 对调 [2][1] [5][6] 对调
for(int i = 0; i < 64; i++)
{
int x = random.nextInt(8);
int y = random.nextInt(8);
String b1 = ap88[x][y];
String b2 = ap88[7-x][7-y];
String b3 = ap88[y][x];
String b4 = ap88[7-y][7-x];
ap88[x][y] = b2;
ap88[7-x][7-y] = b1;
ap88[y][x] = b4;
ap88[7-y][7-x] = b3;
}
//输出
for (String[] bs : ap88) {
for (String b : bs) {
System.out.print(b);
}
System.out.println();
}