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.WriteLine("晴输入年份year:");
int year = Convert.ToInt32(Console.ReadLine());
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
{
Console.WriteLine("{0}是闰年", year);
}
else
{
Console.WriteLine("{0}不是闰年", year);
}
}
}
}
条件判断也可以如下写
if (year % 400 == 0 || (year % 4 == 0 && !(year % 100== 0)))
{
Console.WriteLine("{0}是闰年", year);
}
else
{
Console.WriteLine("{0}不是闰年", year);
}
最后
以上就是勤奋鞋垫最近收集整理的关于c# 判断年份是否为闰年的全部内容,更多相关c#内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复