public static void main(int k, int[][] a) {
int n = 1;
for (int i = 1; i <= k; i++)
n *= 2;
for (int i = 1; i <= n; i++)
a[1][i] = i;
int m = 1;
for (int s = 1; s <= k; s++) {
n /= 2;
for (int t = 1; t <= n; t++)
for (int i = m + 1; i < 2 * m; i++)
for (int j = m + 1; j <= 2 * m; j++) {
a[i][j + (t - 1) * m * 2] = a[i - m][j + (t - 1) * m
* 2 - m];
a[i][j + (t - 1) * m * 2 - m] = a[i - m][j + (t - 1)
* m * 2];
m *= 2;
}
}
System.out.println("你输入了数字" + k);
for (int i = 0; i <= n - 1; i++)
for (int j = 0; j <= n - 1; j++)
System.out.println(a[i][j]);
}
程序我给你改完了,把这个加你的类里就行了,我就那闷你的两个for 循环里怎以都没定义变量呀。