C#--判斷某年是否是閏年

iamzxf發表於2015-03-24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace third
{
    class Program
    {
        static void Main(string[] args)
        {
            int year;
            if (int.TryParse(Console.ReadLine(), out year))
            {
                if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0)))
                    Console.WriteLine("yes");
                else
                    Console.WriteLine("no");
            }
            else
                Console.WriteLine("input error, try again");

            Console.ReadLine();
        }
    }
}

相關文章