Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
31
Task/Chinese-zodiac/Go/chinese-zodiac.go
Normal file
31
Task/Chinese-zodiac/Go/chinese-zodiac.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
var (
|
||||
animalString = []string{"Rat", "Ox", "Tiger", "Rabbit", "Dragon", "Snake",
|
||||
"Horse", "Goat", "Monkey", "Rooster", "Dog", "Pig"}
|
||||
stemYYString = []string{"Yang", "Yin"}
|
||||
elementString = []string{"Wood", "Fire", "Earth", "Metal", "Water"}
|
||||
stemCh = []rune("甲乙丙丁戊己庚辛壬癸")
|
||||
branchCh = []rune("子丑寅卯辰巳午未申酉戌亥")
|
||||
)
|
||||
|
||||
func cz(yr int) (animal, yinYang, element, stemBranch string, cycleYear int) {
|
||||
yr -= 4
|
||||
stem := yr % 10
|
||||
branch := yr % 12
|
||||
return animalString[branch],
|
||||
stemYYString[stem%2],
|
||||
elementString[stem/2],
|
||||
string([]rune{stemCh[stem], branchCh[branch]}),
|
||||
yr%60 + 1
|
||||
}
|
||||
|
||||
func main() {
|
||||
for _, yr := range []int{1935, 1938, 1968, 1972, 1976} {
|
||||
a, yy, e, sb, cy := cz(yr)
|
||||
fmt.Printf("%d: %s %s, %s, Cycle year %d %s\n",
|
||||
yr, e, a, yy, cy, sb)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue