判断生日

          try
            {
                Console.Write("请输入您的生日");
                DateTime a = DateTime.Parse(Console.ReadLine());//闰年限定
                DateTime b = DateTime.Today;

                int ayear = a.Year;
                int amonth = a.Month;
                int aday = a.Day;
                int byear = b.Year;

                TimeSpan c = a - b;

                Console.WriteLine(c.TotalDays);

                int d = (int)c.TotalDays;
                int e = d % 365;
                Console.WriteLine(e);
                
                    Console.WriteLine("您的生日是今年的第" + a.DayOfYear + "");
                    if (byear % 4 != 0 && byear % 400!=0)
              {
                    if (c.TotalDays < 0 && e!=0)
                    {
                        Console.WriteLine("今年您的生日已经过了" + "距离您下个生日还有" + (e + 365) + "");
                    }
                    if (c.TotalDays > 0)
                    {
                        Console.WriteLine("距离您今年过生日还有" + c.TotalDays + "");
                    }
                    if (e == 0)//不执行
                    {
                        Console.WriteLine("祝您生日快乐");
                    }
          }
                else
                    Console.WriteLine("今年没有您的生日哦,请期待下一个闰年吧");
            }
            catch
            { Console.WriteLine("抱歉,您输入错误"); }

            Console.ReadLine();

 

转载于:https://www.cnblogs.com/nwj-0613/p/4712487.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值