• 3月8日 Switch case


    //输入年月日,判断是否正确
                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();
  • 相关阅读:
    Python学习-if条件语句
    Python学习-变量
    认识Python
    win7分盘
    mysql环境变量配置
    mysql的下载及配置
    c# excel xls保存
    js 在线引用
    js layer.js
    vue day3 bootstrap 联动下拉
  • 原文地址:https://www.cnblogs.com/dongqiaozhi/p/5253751.html
Copyright © 2020-2023  润新知