C#基础-006(3) 判断一个年份是否为闰年

来源:互联网 发布:windows日志查询 编辑:程序博客网 时间:2024/06/09 15:07

//满足闰年的条件:
// 能被4整除 并且不能被100整除
//能被400整除
Console.WriteLine(” 请输入年份:”);
int year = int.Parse(Console.ReadLine());
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
{
Console.WriteLine(“这是一个闰年”);
}
else
{
Console.WriteLine(“这是一个平年”);
}