摘要:Chinese Zodiac Selector (出生日期轉換為天干地支及生肖)
非常簡單但是要用又找不到,自己寫一個(程式沒有將日期轉換為農曆,所以請勿直接拿去用,會有例外的錯誤判斷).

BOOL GetChiZodiac(
int nYear,
char* pcChiZodic)

...{
char* ppcTianGan[] = ...{ "甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸" };
char* ppcDiZhi[] = ...{ "子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥" };
char* ppcChiZodic[] = ...{ "鼠", "牛", "虎", "兔", "龍", "蛇", "馬", "羊", "猴", "雞", "狗", "豬" };
int nJia, nTianGan, nDiZhi;
nJia = (nYear - 3) % 60 - 1;
nJia += 60;
nTianGan = nJia % 10;
nDiZhi = nJia % 12;
strcpy(pcChiZodic, ppcChiZodic[nDiZhi]);
printf("天干: %s 地支: %s 生肖: %s\n", ppcTianGan[nTianGan], ppcDiZhi[nDiZhi], ppcChiZodic[nDiZhi]);
return TRUE;
} 參考公式:天干地支.rar
國曆農曆轉換請參考此篇
