首页 > 其他 > 详细

判断闰平年

时间:2015-06-18 15:12:07      阅读:310      评论:0      收藏:0      [点我收藏+]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 判断闰平年
{
    class Program
    {
        static void Main(string[] args)
        {                                    
                Console.Write("请输入年份:");
                double a = Convert.ToDouble(Console.ReadLine());
                if(a > 0)                      //可以写作: if (year%400==0||(year%4==0&&year %100 !=0) )
                {                      
                   if(a%4==0&&a%100!=0)
                    {                                           
                          Console.WriteLine("{0}是闰年", a);                      
                    }
                   else if (a % 100 == 0 && a % 400 == 0)
                    {
                          Console.WriteLine("{0}是闰年", a);
                    }
                   else
                    {
                          Console.WriteLine("{0}是平年", a);
                    }
                }
                else
                {
                    Console.WriteLine("请输入正确的年份");
                }
                Console.ReadLine();
            }
          }
    }
}

 

判断闰平年

原文:http://www.cnblogs.com/qixinjian/p/4585685.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!