//满足闰年的条件:
// 能被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(“这是一个平年”);
}
C#基础-006(3) 判断一个年份是否为闰年
最新推荐文章于 2024-01-23 21:46:24 发布