欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

判断星座

程序员文章站 2022-03-18 16:03:02
2018-11-11 17:12:34 开始写 ......

2018-11-11  17:12:34 开始写

 1 public static string getconstellation(int month, int day)
 2       {
 3         string[] constellations = { "魔蝎座", "水瓶座", "双鱼座", "白羊座", "金牛座", "双子座", 
 4           "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座" };
 5         int[] divide = { 19, 18, 20, 19, 20, 21, 22, 22, 22, 23, 22, 21 };
 6         if (day <= divide[(month - 1)]) {
 7           return constellations[(month - 1)];
 8         }
 9         if (month >= 12) {
10             month = 0;
11         }
12         return constellations[month];
13       }