zoukankan      html  css  js  c++  java
  • 判断年月日是否正确

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                 while (true)
                {
                    Console.Write("请输入年份:");
                    int year = int.Parse(Console.ReadLine());
                    Console.Write("请输入月份:");
                    int yue = int.Parse(Console.ReadLine());
                    Console.Write("请输入日期:");
                    int riqi = int.Parse(Console.ReadLine());
    
                    if (year > 0 && year < 9999)
                    {
                        if (yue == 1 || yue == 3 || yue == 5 || yue == 7 || yue == 8 || yue == 10 || yue == 12)
                        {
                            if (riqi > 0 && riqi <= 31)
                            {
                                Console.WriteLine("你输入的日期正确,请继续努力!");
                            }
                            else
                            {
                                Console.WriteLine("请输入正确的日期,谢谢。");
                            }
                        }
                        else if (yue == 4 || yue == 6 || yue == 9 || yue == 11)
                        {
                            if (riqi > 0 && riqi <= 30)
                            {
                                Console.WriteLine("你输入的日期正确,请继续努力!");
                            }
                            else
                            {
                                Console.WriteLine("请输入正确的日期,谢谢。");
                            }
                        }
                        else if (yue == 2)
                        {
                            if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
                            {
                                if (riqi > 0 && riqi <= 29)
                                {
                                    Console.WriteLine("你输入的日期正确,请继续努力");
                                }
                                else
                                {
                                    Console.WriteLine("请输入正确的日期,谢谢。");
                                }
                            }
                            else
                            {
                                if (riqi > 0 && riqi <= 28)
                                {
                                    Console.WriteLine("你输入的日期正确,请继续努力");
                                }
                                else
                                {
                                    Console.WriteLine("请输入正确的日期,谢谢。");
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("请输入正确的日期,谢谢。");
                        }
                    }
                    else
                    {
                        Console.WriteLine("请输入正确的日期,谢谢。");
                    }
                    Console.ReadLine();
                }
            }
        }
    }
  • 相关阅读:
    使用PHP类库PHPqrCode生成二维码
    ABAP报表中建立过滤器,并相互切换
    MM定价计算方案确定详细图解
    MIGO 屏幕增强
    SE14 激活表时提示进程正在运行
    供应商寄售
    屏蔽VA01的TA類型的銷售部門和銷售組
    屏蔽標準TCODE上的一些字段的顯示、隱藏或者強制輸入(轉)
    采购订单流程
    SAP 中如何修改透明表数据
  • 原文地址:https://www.cnblogs.com/qixinjian/p/4586026.html
Copyright © 2011-2022 走看看