Problems B: Analyzing leap year

Title Description

Use a console application written in C #. Input - a year, it is determined whether or not a leap year (divisible by four, and not divisible by 100, or 400 to be divisible).
Is a leap year output yes, not no output

Entry

A Year

Export

yes or no

Sample input

1996

Sample Output

yes

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Helloworld
{
    class Program
    {
        static void Main(string[] args)
        {
            int year = Convert.ToInt32(Console.ReadLine());
            if ((year % 4 == 0) && (year % 100 != 0) || year % 400 == 0)
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }
            Console.ReadKey();
        }
    }
}

  

Guess you like

Origin www.cnblogs.com/mjn1/p/12402651.html