实验要求:输入一个年份,判断是否润年(被4整除,且不被100整除,或者被400整除)
源代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1dishizhou1
{
class Program
{
static void Main(string[] args)
{
Console.Write("请输入一个年份:");
string str = Console.ReadLine();
int n = int.Parse(str);
if (n % 4 == 0 && n % 100 != 0 || n % 400 == 0)
{
Console.WriteLine(n + "是闰年");
}
else
{
Console.WriteLine(n + "不是闰年");
}
Console.ReadLine();
}
}
}
输出结果:
总结:Console.ReadLine();此语句用于用于停留界面;