zoukankan      html  css  js  c++  java
  • 判断生日

              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();
  • 相关阅读:
    LeetCode
    LeetCode
    Django ORM 查询
    The Usage of Pymongo
    MongoDB基操
    Django内置auth模块中login_required装饰器用于类视图的优雅方式
    Django Session配置
    Python虚拟环境
    遇见Flask-Script
    Git使用手册
  • 原文地址:https://www.cnblogs.com/nwj-0613/p/4712487.html
Copyright © 2011-2022 走看看