zoukankan      html  css  js  c++  java
  • 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();
  • 相关阅读:
    AM8 自定义表情包的实现方法
    Create STKNetDiskC Instance Error
    怎样实现文件发文功能
    企业云盘的数据备份
    一种可行的文档协同编辑方法实现
    【OI】二分图最大匹配
    【OI】位运算操作
    【OI】关于快速幂的简单理解
    【OI】线性筛
    【OI】指针线段树&指针
  • 原文地址:https://www.cnblogs.com/dongqiaozhi/p/5253751.html
Copyright © 2011-2022 走看看