您当前的位置: 首页 >  郭梧悠 算法

有关回旋数的算法(二)

郭梧悠 发布时间:2012-02-29 22:45:15 ,浏览量:4

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package arthur.datastruct.suanfa;


/**
 *
 * @author dell
 */
public class HuiXing {
    
    public static void main(String[] args) {
        int a[][] = getArray1(4);
        System.err.println();
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a.length; j++) {
                System.out.print(a[i][j] + " ");
            }
            
            System.out.println();
        }
    }


    
    public static int[][] getArray1(int n) {
        int arr[][] = new int[2 * n - 1][2 * n - 1];
        
        int rowMin = 0;
        int rowMax = arr.length - 1;
        int colMin = 0;
        int colMax = arr.length - 1;
        while (n != 0) {
            if (1 == n) {
                int center = (arr.length - 1) >> 1;
                arr[center][center] = 1;
                break;
            } else {


                //为最上面的那一行赋值
                for (int i = colMin; i
关注
打赏
查看更多评论

郭梧悠

暂无认证

  • 4浏览

    0关注

    339博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录