3月8日 Switch case
发布日期:2021-08-13 19:50:30 浏览次数:3 分类:技术文章

本文共 2616 字,大约阅读时间需要 8 分钟。

//输入年月日,判断是否正确            Console.WriteLine("输入一个年份");            int year = int.Parse(Console.ReadLine());            Console.WriteLine("输入一个月份");            int month = int.Parse(Console.ReadLine());            Console.WriteLine("输入一个日期");            int date = int.Parse(Console.ReadLine());            if (year >= 0 && year <= 9999)            {                Console.WriteLine(year+"年");                if (month >= 1 && month <= 12)                {                    Console.WriteLine(month+"月");                    if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)                    {                        if(date>=1&&date<=31)                    {                        Console.WriteLine(+date+"号");                    }                        else                        {                            Console.WriteLine("您输入的日期有误");                        }                    }                    else if(month==4||month==6||month==9||month==11)                    {                        if(date>=1&&date<=30)                        {                            Console.WriteLine(+date+"号");                        }                        else                        {                            Console.WriteLine("您输入的日期有误");                        }                    }                    else                    {                        if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0)                    {                            if(date>=1&&date<=29)                            {                                Console.WriteLine(+date+"号");                            }                            else                            {                                Console.WriteLine("您输入的日期有误");                            }                    }                        else                        {                            if(date>=1&&date<=28)                        {                                Console.WriteLine(+date+"号");                            }                            else                            {                                Console.WriteLine("您输入的日期有误");                            }                        }                                            }                                                                    }                 else                {                    Console.WriteLine("您输入的月份有误");                }            }                       else    {                                Console.WriteLine("您输入的年份有误");        }            Console.ReadLine();

 

转载于:https://www.cnblogs.com/dongqiaozhi/p/5253751.html

转载地址:https://blog.csdn.net/weixin_30699235/article/details/99124274 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:PowerShell管道入门,看看你都会不(管道例子大全)
下一篇:div.2/Bellovin<最长上升子序列>

发表评论

最新留言

很好
[***.229.124.182]2024年03月29日 08时54分58秒