判断闰平年

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();
            }
          }
    }
}
原文地址:https://www.cnblogs.com/qixinjian/p/4585685.html