Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
49
Task/Long-year/S-BASIC/long-year.basic
Normal file
49
Task/Long-year/S-BASIC/long-year.basic
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
$lines
|
||||
|
||||
rem - compute p mod q
|
||||
function mod(p, q = integer) = integer
|
||||
end = p - q * (p/q)
|
||||
|
||||
comment
|
||||
return day of week (Sun = 0, Mon = 1, etc.) for a
|
||||
given Gregorian calendar date using Zeller's congruence
|
||||
end
|
||||
function dayofweek (mo, da, yr = integer) = integer
|
||||
var y, c, z = integer
|
||||
if mo < 3 then
|
||||
begin
|
||||
mo = mo + 10
|
||||
yr = yr - 1
|
||||
end
|
||||
else mo = mo - 2
|
||||
y = mod(yr,100)
|
||||
c = int(yr / 100)
|
||||
z = int((26 * mo - 2) / 10)
|
||||
z = z + da + y + int(y/4) + int(c/4) - 2 * c + 777
|
||||
z = mod(z,7)
|
||||
end = z
|
||||
|
||||
comment
|
||||
The simplest of several possible tests is that
|
||||
any calendar year starting or ending on a
|
||||
Thursday is "long", i.e., has 53 ISO weeks
|
||||
end
|
||||
function islongyear(yr = integer) = integer
|
||||
var thursday, result = integer
|
||||
thursday = 4
|
||||
if (dayofweek(1,1,yr) = thursday) or \
|
||||
(dayofweek(12,31,yr) = thursday) then
|
||||
result = -1 rem "true"
|
||||
else
|
||||
result = 0 rem "false"
|
||||
end = result
|
||||
|
||||
rem - main program begins here
|
||||
|
||||
var year = integer
|
||||
print "ISO years that will be long in this century:"
|
||||
for year = 2000 to 2099
|
||||
if islongyear(year) then print year;
|
||||
next year
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue