投入-年份
输出-是否为Leap year
我试过了
Program LeapYear;
var
Year:Integer
begin
writeln('Insert year');
readln(Year)
if Year MOD 4 = 0 and Year MOD 100 = 0 and not Year MOD 400 = 0 then
begin
writeln(Year,'is leap year')
end
else
begin
writeln(Year,'is not leap year')
end
end.但这并不管用
发布于 2012-11-25 04:54:46
你的算法是错的。它应该是:
if (year mod 400 = 0) or ((year mod 4 = 0) and not (year mod 100 = 0))发布于 2012-11-26 22:51:06
datih.inc文件中已经定义了IsLeapYear函数,因此您不需要编写自己的版本,只需添加sysutils单元即可。
发布于 2018-05-21 01:35:04
希望它能有所帮助:
if((a MOD 4) = 0) and ((a MOD 100) = 0) and ((a MOD 400) = 0) then y:=true
else y:=false;https://stackoverflow.com/questions/13545434
复制相似问题