• 4.28.FOR循环及其练习


    if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)

                        {

                            if (d <= 31 && d > 0)//日期输入正确

                            {

                                Console.WriteLine("日期输入正确!");

                                Console.WriteLine(y + "年" + m + "月" + d + "日");

                            }

                            else

                            {

                                Console.WriteLine("日期输入有误!");

                            }

                        }

                        else if (m == 4 || m == 6 || m == 9 || m == 11)//输入的是小月

                        {

                            if (d <= 30 && d > 0)//日期输入正确

                            {

                                Console.WriteLine("日期输入正确!");

                                Console.WriteLine(y + "年" + m + "月" + d + "日");

                            }

                            else

                            {

                                Console.WriteLine("日期输入有误!");

                            }

                        }

                        else if (m == 2)//如果是2月

                        {

                            //判断是否是闰年

                            //年份可以被4整除 并且 不能被100整除

                            //特殊年:或者,年份可以被400整除

                            if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)//说明当前是闰年

                            {

                                if (d <= 29 && d > 0)//日期正确

                                {

                                    Console.WriteLine("日期输入正确!");

                                    Console.WriteLine(y + "年" + m + "月" + d + "日");

                                    Console.WriteLine(y + "年是闰年!");

                                }

                                else//日期错误

                                {

                                    Console.WriteLine("日期输入有误!");

                                }

                            }

                            else//说明不是闰年

                            {

                                if (d <= 28 && d > 0)//日期正确

                                {

                                    Console.WriteLine("日期输入正确!");

                                    Console.WriteLine(y + "年" + m + "月" + d + "日");

                                    Console.WriteLine(y + "年不是闰年!");

                                }

                                else//日期错误

                                {

                                    Console.WriteLine("日期输入有误!");

                                }

                            }

                        }

                    }

                    else//月份错误

                    {

                        Console.WriteLine("月份输入有误!");

                    }

                }

                else//年份输入错误

                {

                    Console.WriteLine("年份输入有误!");

                }

     

                Console.ReadLine();

            }

        }

    }

  • 相关阅读:
    Redis
    Redux架构
    Dapper.NET
    JS的异步模式
    Session Redis Nginx
    .NET CORE的TagHelper智能提示
    一个Redis实现的分布式锁
    Redisson使用起来很方便,但是需要redis环境支持eval命令
    The Little Redis Book
    mybatis UpdateByExampleMapper UpdateByExampleSelectiveMapper
  • 原文地址:https://www.cnblogs.com/suiyuejinghao123/p/5454574.html
Copyright © 2020-2023  润新知