2022年天干地支对照表,java实现

良田百顷,不在一亩;但有远志,不在当归

2022年天干地支对照表 干支日历表

生辰八字

干支纪年

为什么不会有甲丑年

农历月份

三九天

2022年三九天时间表

干支

什么是十二地支?地支由来详解

一文读懂阳历、阴历、公历、农历

//儒以文乱法,而侠以武犯禁
package test;
import java.util.Arrays;
public class Days {
    public static void main(String[] args) {
        String[] sky = {"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"};
        String[] ground = {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"};
        int count = 0;
        int n = 0;
        String[] year = new String[60];
        for (int i = 0; i < sky.length; i++) {
            for (int j = 0; j < ground.length; j++) {
                if ((i & 1) == 1 && (j & 1) == 1||(i & 1) == 0 && (j & 1) == 0) {
                    year[j] = sky[i] + ground[j];
                    System.out.print(year[j] + " ");
                    count++;
                    n++;
                    if (n == 6) {
                        System.out.print("\n---------------------------------\n");
                        n = 0;
                    }
                }
            }
        }
        System.out.println("count = " + count);
    }
}

在这里插入图片描述

用数组存贮总犯错,原因未知,用list就没问题

import java.util.ArrayList;

public class Days {
    public static void main(String[] args) {
        String[] sky = {"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"};
        String[] ground = {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"};
        ArrayList<String> list = new ArrayList<>();
        int count = 0;
        int n = 0;
        String[] year = new String[60];
        String[] copy = new String[60];
        for (int i = 0; i < sky.length; i++) {
            for (int j = 0; j < ground.length; j++) {
                if ((i & 1) == 1 && (j & 1) == 1 || (i & 1) == 0 && (j & 1) == 0) {
                    year[j] = sky[i] + ground[j];
                    list.add(year[j]);
                    System.out.print(year[j] + " ");
                    count++;
                    n++;
                    if (n == 6) {
                        System.out.print("\n---------------------------------\n");
                        n = 0;
                    }
                }
                for (int k = 0; k < copy.length; k++) {
                    copy[k] = year[j];
                }
            }
        }
        int m = 0;
        System.out.print("count = " + count);
        System.out.print("\n---------------------------------------------------\n");
        for (String s : list) {
            System.out.print((s) + " ");
            m++;
            if (m == 12) {
                System.out.print("\n---------------------------------------------------\n");
                m = 0;
            }
        }
        int p = 0;
        System.out.print("count = " + count);
        System.out.print("\n---------------------------------------------------\n");
        for (int i = 0; i < year.length; i++) {
            System.out.print(year[i] + " ");
            p++;
            if (p == 12) {
                System.out.print("\n---------------------------------------------------\n");
                p = 0;
            }
        }
        int q = 0;
        System.out.print("count = " + count);
        System.out.print("\n---------------------------------------------------\n");
        for (int i = 0; i < copy.length; i++) {
            System.out.print(copy[i] + " ");
            q++;
            if (q == 12) {
                System.out.print("\n---------------------------------------------------\n");
                q = 0;
            }
        }
    }
}

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值