码迷,mamicode.com
首页 > 其他好文 > 详细

判断闰平年

时间:2015-06-18 15:13:21      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:

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.Write("请输入年份:");
                double a = Convert.ToDouble(Console.ReadLine());
                if(a > 0)                      //可以写作: if (year%400==0||(year%4==0&&year %100 !=0) )
                {                      
                   if(a%4==0&&a%100!=0)
                    {                                           
                          Console.WriteLine("{0}是闰年", a);                      
                    }
                   else if (a % 100 == 0 && a % 400 == 0)
                    {
                          Console.WriteLine("{0}是闰年", a);
                    }
                   else
                    {
                          Console.WriteLine("{0}是平年", a);
                    }
                }
                else
                {
                    Console.WriteLine("请输入正确的年份");
                }
                Console.ReadLine();
            }
          }
    }
}

 

判断闰平年

标签:

原文地址:http://www.cnblogs.com/qixinjian/p/4585685.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!