良田百顷,不在一亩;但有远志,不在当归
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); } }
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]; 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]; System.out.print(year[j] + " "); for (int k = 0; k < copy.length; k++) { copy[k] = year[j]; } count++; n++; if (n == 6) { System.out.print("n---------------------------------n"); n = 0; } } } } int m = 0; System.out.print("count = " + count); System.out.print("n---------------------------------n"); for (int i = 0; i < copy.length; i++) { System.out.print(copy[i] + " "); m++; if (m == 6) { System.out.print("n---------------------------------n"); m = 0; } } } }
用数组存贮总犯错,原因未知,用list就没问题
package test; import java.util.ArrayList; public class Days { public static void main(String[] args) { String[] sky = {"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"}; String[] ground = {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"}; ArrayListlist = 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 < copy.length; i++) { System.out.print(copy[i] + " "); p++; if (p == 12) { System.out.print("n---------------------------------------------------n"); p = 0; } } } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)