Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
28
Task/Leap-year/S-BASIC/leap-year.basic
Normal file
28
Task/Leap-year/S-BASIC/leap-year.basic
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
rem - compute p mod q
|
||||
function mod(p, q = integer) = integer
|
||||
end = p - q * (p/q)
|
||||
|
||||
rem - return true (-1) if y is a leap year, otherwise 0
|
||||
function isleapyear(y = integer) = integer
|
||||
end = mod(y,4)=0 and mod(y,100)<>0 or mod(y,400)=0
|
||||
|
||||
rem - exercise the function
|
||||
var y = integer
|
||||
|
||||
print "Test of century years"
|
||||
for y = 1600 to 2000 step 100
|
||||
if isleapyear(y) then
|
||||
print y;" is a leap year"
|
||||
else
|
||||
print y;" is NOT a leap year"
|
||||
next y
|
||||
|
||||
print "Test of current half-decade"
|
||||
for y = 2015 to 2020
|
||||
if isleapyear(y) then
|
||||
print y; " is a leap year"
|
||||
else
|
||||
print y; " is NOT a leap year"
|
||||
next y
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue