close

/**
 * @(#)magic5.java
 * @author:Arthur
 * @note:魔術方塊(邊長5)
 * @version 1.00 2007/10/4
 */


public class magic5 {

    public static void main(String args[]) {
     int num[][]=new int[5][5];
     int x=4,y=2,z=1;
     while (true){
      if (num[x][y]==0) num[x][y]=z;
      x++;
      y++;
      if (x==5) x=0;
      if (y==5) y=0;
      if (num[x][y]!=0){
       x=x-2;
       y--;
       if (y==-1) y=4;
       if (x==-1) x=4;
       if (x==-2) x=3;
      }
      z++;
      if (z>=26) break;
     }
     for (int i=0;i       for (int j=0;j       System.out.println();
     }
    }
}
--------------------Configuration: --------------------
11  18  25  2   9  
10  12  19  21  3  
4   6   13  20  22 
23  5   7   14  16 
17  24  1   8   15 

Process completed.

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 浮雲 的頭像
    浮雲

    missice's Blog

    浮雲 發表在 痞客邦 留言(3) 人氣()