C# 判断是否为闰年的条件各是
2015-05-18 21:21
447 查看
//try 没增加异常数据处理 Console.WriteLine("根据输入的信息计算当年某个月份的天数,以及当年是否是闰年或平年,\n并判断2月份特殊月份的天数。"); Console.WriteLine("请输入需要计算的年份:"); int year = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("请输入需要获取的月份"); int month = Convert.ToInt32(Console.ReadLine()); switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: Console.WriteLine("是31天"); break; case 2: if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0) //闰年的判断条件格式 // 如果 年能被400整除 或者 年能被4整除 并且年不能被100整除。 { Console.WriteLine("是闰年,2月当月的天数有29天"); } else { Console.WriteLine("是平年,2月当月的天数有28天"); } break; default: Console.WriteLine("为30天"); break; }
相关文章推荐
- Java基础应用之条件语句(实判断某一年是否为闰年)
- 【C#】简单窗体程序,判断是否闰年,禁止窗体调整大小,关闭窗体前的判断
- C#、vb.net及SQL判断指定年份是否为闰年的方法
- 作业3-4 循环输入多个年份 year,判断该年是否为闰年。判断闰年的条件是:能被 4 整除但不能被100 整除,或者能被 400 整除。输入-1退出程序执行
- 简单实现C#窗体程序判断是否闰年
- c#简单判断是否是闰年的方法代码
- C#或VB.NET判断指定的年份是否为闰年
- C#练习——判断年份是否为闰年,九九乘法表,十进制转二进制数
- C#基础-006(3) 判断一个年份是否为闰年
- [C#]方法示例:判断是否闰年
- 作业3(4)循环输入多个年份 year,判断该年是否为闰年。判断闰年的条件是:能被 4 整除但不能被100 整除,或者能被 400 整除。输入-1退出程序执行
- 作业3-4 循环输入多个年份 year,判断该年是否为闰年。判断闰年的条件是:能被 4 整除但不能被100 整除,或者能被 400 整除。输入-1退出程序执行
- 《判断年份是否为闰年——C#第一周》
- 4、判断一个年份是否为闰年。(闰年即满足以下两条件的年份:其一:能被4整除但不能被100整除;其二:能被400带除)
- C#中怎么判断一个数组中是否存在某个数组值
- C#判断字符串是否为数字字符串(转)
- C# 判断是否图片格式
- C#--判断某年是否是闰年
- C#判断文件路径是否存在或者判断文件是否存在
- C#服务端判断客户端socket是否已断开的方法