我是靠谱客的博主 勤奋鞋垫,这篇文章主要介绍c# 判断年份是否为闰年,现在分享给大家,希望可以做个参考。

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#内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(65)

评论列表共有 0 条评论

立即
投稿
返回
顶部