欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 家装 > 生日判断星座【GO】

生日判断星座【GO】

2024/11/30 11:28:44 来源:https://blog.csdn.net/qq_40374604/article/details/140289949  浏览:    关键词:生日判断星座【GO】

文章目录

    • 星座列表
    • 生日转换为星座

星座列表

const (Aries       = "aries"Taurus      = "taurus"Gemini      = "gemini"Cancer      = "cancer"Leo         = "leo"Virgo       = "virgo"Libra       = "libra"Scorpio     = "scorpio"Sagittarius = "sagittarius"Capricorn   = "capricorn"Aquarius    = "aquarius"Pisces      = "pisces"
)

生日转换为星座

package mainimport ("fmt""time"
)func getZodiac(month int, day int) string {switch {case month == 12 && day >= 22:return "摩羯座"case month == 1 && day <= 19:return "摩羯座"case month == 1 && day >= 20:return "水瓶座"case month == 2 && day <= 18:return "水瓶座"case month == 2 && day >= 19:return "双鱼座"case month == 3 && day <= 20:return "双鱼座"case month == 3 && day >= 21:return "白羊座"case month == 4 && day <= 19:return "白羊座"case month == 4 && day >= 20:return "金牛座"case month == 5 && day <= 20:return "金牛座"case month == 5 && day >= 21:return "双子座"case month == 6 && day <= 20:return "双子座"case month == 6 && day >= 21:return "巨蟹座"case month == 7 && day <= 22:return "巨蟹座"case month == 7 && day >= 23:return "狮子座"case month == 8 && day <= 22:return "狮子座"case month == 8 && day >= 23:return "处女座"case month == 9 && day <= 22:return "处女座"case month == 9 && day >= 23:return "天秤座"case month == 10 && day <= 22:return "天秤座"case month == 10 && day >= 23:return "天蝎座"case month == 11 && day <= 21:return "天蝎座"case month == 11 && day >= 22:return "射手座"case month == 12 && day <= 21:return "射手座"default:return "未知星座"}
}func main() {var timestamp int64fmt.Println("请输入您的出生时间戳(秒级): ")fmt.Scanln(&timestamp)// 将时间戳转换为 time.Time 对象t := time.Unix(timestamp, 0)// 获取月份和日期month := int(t.Month())day := t.Day()// 确定星座zodiac := getZodiac(month, day)fmt.Printf("您的星座是: %s\n", zodiac)
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com