zoukankan      html  css  js  c++  java
  • 分别录入年月日,判断是否是一个正确的日期


    Console.WriteLine("请输入年");
    string year = Console.ReadLine();
    int x = int.Parse(year);
    Console.WriteLine("请输入月");
    string month = Console.ReadLine();
    int y = int.Parse(month);
    Console.WriteLine("请输入日");
    string day = Console.ReadLine();
    int z = int.Parse(day);

    if ((y == 1) || (y == 3) || (y == 5) || (y == 7) || (y == 8) || (y == 10) || (y == 12))
    {
    if ((z >= 1) && (z <= 31))
    {
    Console.WriteLine("输入正确");
    }
    else
    Console.WriteLine("请输入正确的日");
    }
    else if (y == 2)
    {
    if ((x % 4 == 0 && x % 100 != 0) || (x % 400 == 0))
    {
    if ((z >= 1) && (z <= 29))
    {
    Console.WriteLine("输入正确");
    }
    Console.WriteLine("请输入正确的日");
    }
    else if (x % 4 != 0)
    {
    if ((z >= 1) && (z <= 28))
    {
    Console.WriteLine("输入正确");
    }
    Console.WriteLine("请输入正确的日");
    }
    }
    else if((y==4)||(y==6)||(y==9)||(y==11))
    {
    if ((z >= 1) && (z <= 30))
    {
    Console.WriteLine("输入正确");
    }
    else
    Console.WriteLine("请输入正确的日");
    }
    else
    Console.WriteLine("请输入正确的月");
    Console.ReadLine();

  • 相关阅读:
    初学AOP
    通过工厂方式配置bean
    Spring中Bean的生命周期方法
    Spring中配置文件中引用外部文件
    Spring中的SPEL
    Spring中的自动装配
    初学Spring
    暑假写的有关字符串处理的程序
    linux查看所有用户信息
    python 函数enumerate(x,y)的用法
  • 原文地址:https://www.cnblogs.com/yangyue/p/4161850.html
Copyright © 2011-2022 走看看