/**
* @(#)magic3.java
* @author:Arthur
* @note:魔術方塊(邊長3)
* @version 1.00 2007/10/4
*/
public class magic3 {
public static void main(String args[]) {
int num[][]=new int[3][3];
int x=2,y=1,z=1;
while (true){
if (num[x][y]==0) num[x][y]=z;
x++;
y++;
if (x==3) x=0;
if (y==3) y=0;
if (num[x][y]!=0){
x=x-2;
y--;
if (y==-1) y=2;
if (x==-1) x=2;
if (x==-2) x=1;
}
z++;
if (z>=10) break;
}
for (int i=0;i
for (int j=0;j
System.out.println();
}
}
}
--------------------Configuration:
4 9 2
3 5 7
8 1 6
Process completed.
留言列表