美文网首页
第四次作业第二题

第四次作业第二题

作者: 孤独是种安全感_b7bf | 来源:发表于2018-10-31 19:06 被阅读0次

代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
/**
* 1判断闰年的表达式,设待判断的年份变量为year.
* 2 年份能够被400整除.
* 3 年份能够被4整除但不能被100整除
* 4让用户输入一个年份,如果是润年,则输出true,如果不是,则输出false
*
* */
//提示用户输入
Console.WriteLine("请输入一个年份");
//接受用户输入
string stryear = Console.ReadLine();
//转换成数字型字符
int year = Convert.ToInt32(stryear);

        //输出比较结果
        bool b = year % 400 == 0 || (year % 4==0 && year % 100 !=0);
        Console.WriteLine("你输入的年份是:{0},此年份是不是闰年:{1}",year,b);
        Console.ReadKey();



    }
}

}

效果

IMG_20181031_151325.jpg

相关文章

网友评论

      本文标题:第四次作业第二题

      本文链接:https://www.haomeiwen.com/subject/wneatqtx.html