zoukankan      html  css  js  c++  java
  • 年月日判断程序

    static void Main(string[] args)
            {
                while (true) //输入某年某月某日判断是该年第多少天
                {
                    int year, mooth, day;
                    Console.Write("请输入年份:");
                    year=int.Parse( Console.ReadLine());
                    if (year > 0 && year <= 9999)
                    {
                        Console.Write("请输入月份:");
                        mooth = int.Parse(Console.ReadLine());
                        if (mooth >= 1 && mooth <= 12)
                        {
                            Console.Write("请输入日期:");
                            day = int.Parse(Console.ReadLine());
                            if((mooth==1||mooth==3||mooth==5||mooth==7||mooth==8||mooth==10||mooth==12)&&(day>=1 && day<=31))
                            {
                                Console.WriteLine("这是"+year+""+mooth+""+day+"");
                            }
                            else if ((mooth == 4 || mooth == 6 || mooth == 9 || mooth == 11) && (day >= 1 && day <= 30))
                            {
                                Console.WriteLine("这是" + year + "" + mooth + "" + day + "");
                            }
                            else if (mooth == 2 && (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) && (day >= 1 && day <= 29)) 
                            {
                                Console.WriteLine("这是" + year + "" + mooth + "" + day + "");
                            }
                            else if (mooth == 2 && (!(year % 400 == 0 || (year % 100 != 0 && year % 4 == 0))) && (day >= 1 && day <= 28))
                            {
                                Console.WriteLine("这是" + year + "" + mooth + "" + day + "");
                            }
                            else
                            {
                                Console.WriteLine("输入日期有误");
                            }
                        }
                        else 
                        {
                            Console.WriteLine("输入月有误");
                        }
                    }
    
                    else 
                    {
                        Console.WriteLine("输入年有误");
                    }

  • 相关阅读:
    2010上交:计算表达式
    添加子评论
    上传图片
    settings配置 文件操作
    django 操作前端数据
    静态文件配置
    render httprequest
    上传文件配置
    Django为什么要跳转到不同的页面来实现不同的功能
    定义日志器
  • 原文地址:https://www.cnblogs.com/wang-kaifeng/p/4792178.html
Copyright © 2011-2022 走看看