39 lines
1.9 KiB
Text
39 lines
1.9 KiB
Text
···
|
|
http://rosettacode.org/wiki/Chinese_zodiac
|
|
···
|
|
■ ChineseZodiac
|
|
§ static
|
|
tiangan⦂ String[][]: ¤ · 10 celestial stems
|
|
¤ "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"
|
|
¤ "jiă", "yĭ", "bĭng", "dīng", "wù", "jĭ", "gēng", "xīn", "rén", "gŭi"
|
|
|
|
dizhi⦂ String[][]: ¤ · 12 terrestrial branches
|
|
¤ "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"
|
|
¤ "zĭ", "chŏu", "yín", "măo", "chén", "sì", "wŭ", "wèi", "shēn", "yŏu", "xū", "hài"
|
|
|
|
wuxing⦂ String[][]: ¤ · 5 traditional elements
|
|
¤ "木", "火", "土", "金", "水"
|
|
¤ "mù", "huǒ", "tǔ", "jīn", "shuǐ"
|
|
¤ "wood", "fire", "earth", "metal", "water"
|
|
|
|
shengxiao⦂ String[][]: ¤ · 12 animal deities
|
|
¤ "鼠", "牛", "虎", "兔", "龍", "蛇", "馬", "羊", "猴", "鸡", "狗", "豬"
|
|
¤ "shǔ", "niú", "hǔ", "tù", "lóng", "shé", "mǎ", "yáng", "hóu", "jī", "gǒu", "zhū"
|
|
¤ "rat", "ox", "tiger", "rabbit", "dragon", "snake", "horse", "goat", "monkey", "rooster", "dog", "pig"
|
|
|
|
yinyang⦂ String[][]: ¤ · 2 fundamental principles
|
|
¤ "阳", "阴"
|
|
¤ "yáng", "yīn"
|
|
|
|
▶ main
|
|
• args⦂ String[]
|
|
for each year ∈ [1935, 1938, 1968, 1972, 1976, 1984, 1985, 1986, 2017]⦂ int
|
|
cycle⦂ int: year - 4
|
|
stem⦂ int: cycle \ 10
|
|
branch⦂ int: cycle \ 12
|
|
System.out.printf "%4s %-8s %-6s %-6s %s\n", year, tiangan[0][stem] ⊕ dizhi[0][branch],
|
|
wuxing[0][stem / 2], shengxiao[0][branch], yinyang[0][year \ 2]
|
|
System.out.printf " %-9s %-7s %-7s %s\n", tiangan[1][stem] ⊕ dizhi[1][branch],
|
|
wuxing[1][stem / 2], shengxiao[1][branch], yinyang[1][year \ 2]
|
|
System.out.printf " %-2s/60 %-7s %s\n\n", cycle \ 60 + 1,
|
|
wuxing[2][stem / 2], shengxiao[2][branch]
|