Day of the week: Difference between revisions
Content added Content deleted
No edit summary |
Not a robot (talk | contribs) (Add Cowgol) |
||
Line 1,455: | Line 1,455: | ||
2118 |
2118 |
||
</pre> |
</pre> |
||
=={{header|Cowgol}}== |
|||
<lang cowgol>include "cowgol.coh"; |
|||
sub weekday(year: uint16, month: uint8, day: uint8): (wd: uint8) is |
|||
if month < 3 then |
|||
month := month + 10; |
|||
year := year - 1; |
|||
else |
|||
month := month - 2; |
|||
end if; |
|||
var c := year / 100; |
|||
var y := year % 100; |
|||
var z := (26 * month as uint16 - 2) / 10; |
|||
z := z + day as uint16 + y + (y / 4) + (c / 4) - 2 * c + 777; |
|||
wd := (z % 7) as uint8; |
|||
end sub; |
|||
var year: uint16 := 2008; |
|||
while year <= 2121 loop |
|||
if weekday(year, 12, 25) == 0 then |
|||
print_i16(year); |
|||
print_nl(); |
|||
end if; |
|||
year := year + 1; |
|||
end loop;</lang> |
|||
{{out}} |
|||
<pre>2011 |
|||
2016 |
|||
2022 |
|||
2033 |
|||
2039 |
|||
2044 |
|||
2050 |
|||
2061 |
|||
2067 |
|||
2072 |
|||
2078 |
|||
2089 |
|||
2095 |
|||
2101 |
|||
2107 |
|||
2112 |
|||
2118</pre> |
|||
=={{header|D}}== |
=={{header|D}}== |