标签:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConditionOperator
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("请输入一个年份:");//屏幕输入提示字符串
            string strYear = Console.ReadLine();//获取用户输入的年份
            int intYear = Int32.Parse(strYear);//将输入的年份转换成int类型
            //计算输入的年份是否为闰年,并利用条件运算符输入“是”或者“不是”
            string strYesOrNo = ((intYear % 400) == 0) || (((intYear % 4) == 0) && ((intYear % 100) != 0)) ? "是" : "不是";
            Console.WriteLine("{0}年{1}闰年", strYear, strYesOrNo);	//输出结果
            Console.ReadLine();
        }
    }
}
计算输入的年份是否为闰年,并利用条件运算符输入“是”或者“不是”
标签:
原文地址:http://www.cnblogs.com/skyay/p/4801866.html