• 关于如何计算星座的记事本


     下面是根据年月日时间获取所属星座

     1  /// <summary>
     2         /// 根据生日过的星座
     3         /// </summary>
     4         /// <param name="birthday"></param>
     5         /// <returns></returns>
     6         public string GetAtomByDateTime(DateTime birthday)
     7         {
     8             string ret = "外星人啊";
     9             float birthdayF = 0.00F;
    10             if(birthday.Month == 1 && birthday.Day < 20)
    11             {
    12                 birthdayF = float.Parse(string.Format("13.{0}", birthday.Day));
    13             }
    14             else
    15             {
    16                 birthdayF = float.Parse(string.Format("{0}.{1}", birthday.Month, birthday.Day));
    17             }
    18             float[] atomBound = { 1.20F, 2.19F, 3.21F, 4.20F, 5.21F, 6.22F, 7.23F, 8.23F, 9.23F, 10.24F, 11.23F, 12.22F, 13.20F };
    19             string[] atoms = { "水瓶座", "双鱼座", "白羊座", "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座", "摩羯座" };
    20 
    21             for (int i = 0; i < atomBound.Length -1; i++)
    22             {
    23                 if (atomBound[i] <= birthdayF && atomBound[i + 1] > birthdayF)
    24                 {
    25                     ret = atoms[i];
    26                     break;
    27                 }
    28             }
    29             return ret;
    30         }

    嘻嘻

    js代码

    function getAstro(month, day) {
                var s = "魔羯水瓶双鱼白羊金牛双子巨蟹狮子处女天秤天蝎射手魔羯";
                var arr = [20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22, 22];
                return s.substr(month * 2 - (day < arr[month - 1] ? 2 : 0), 2);
            }
        </script
    

      

  • 相关阅读:
    Lua笔记
    psp info
    防火墙选项变成灰色解决办法
    server error.分析器错误信息: 未能加载类型. line 1
    [C++][stl]vector、list、deque
    恢复隐藏文件ShowAll.reg
    C++笔记
    C#成员的继承
    C#运算符重载
    .NET每个开发人员现在应该下载的十种必备工具
  • 原文地址:https://www.cnblogs.com/wangdrama/p/7818843.html
Copyright © 2020-2023  润新知