检查给定年份是否为PL / SQL中的leap年
在这里,我们将看到如何使用PL/SQL检查给定年份是否为leap年。在PL/SQL代码中,在一组相关的语句声明内安排了一些命令。
year年检查算法如下。
算法
isLeapYear(year):
begin
if year is divisible by 4 and not divisible by 100, then
it is leap year
else if the number is divisible by 400, then
it is leap year
else
it is not leap year
end示例
DECLARE
year NUMBER := 2012;
BEGIN
IF MOD(year, 4)=0
AND
MOD(year, 100)!=0
OR
MOD(year, 400)=0 THEN
dbms_output.Put_line(year || ' is leap year ');
ELSE
dbms_output.Put_line(year || ' is not leap year.');
END IF;
END;输出结果
2012 is leap year
热门推荐
6 保研的祝福语简短
10 年轻20岁祝福语简短
11 朋友结婚祝福语信息简短
12 女孩婚礼贺卡祝福语简短
13 30段点歌简短祝福语
14 虎年春节祝福语图文简短
15 写给后妈祝福语大全简短
16 简短回复生日祝福语
17 校长送毕业祝福语简短
18 毕业立体贺卡祝福语简短