Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
38
Task/Five-weekends/XPL0/five-weekends.xpl0
Normal file
38
Task/Five-weekends/XPL0/five-weekends.xpl0
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
include c:\cxpl\codes; \intrinsic 'code' declarations
|
||||
|
||||
|
||||
func WeekDay(Year, Month, Day); \Return day of week (0=Sat 1=Sun..6=Fri)
|
||||
int Year, Month, Day;
|
||||
[if Month<=2 then [Month:= Month+12; Year:= Year-1];
|
||||
return rem((Day + (Month+1)*26/10 + Year + Year/4 + Year/100*6 + Year/400) / 7);
|
||||
]; \WeekDay
|
||||
|
||||
|
||||
int MonthTbl, Year, I, C;
|
||||
[MonthTbl:= [1, 3, 5, 7, 8, 10, 12]; \months with 31 days
|
||||
C:= 0;
|
||||
for Year:= 1900 to 2100 do
|
||||
for I:= 0 to 6 do \for all the 31-day months...
|
||||
if WeekDay(Year, MonthTbl(I), 1) = 6 then \first of month is a Friday
|
||||
[C:= C+1; \count this year
|
||||
if C<=5 or C>201-5 then \show first 5 and last 5 years
|
||||
[IntOut(0, Year); ChOut(0, ^ );
|
||||
IntOut(0, MonthTbl(I)); CrLf(0);
|
||||
];
|
||||
];
|
||||
IntOut(0, C); CrLf(0); \show number of years
|
||||
|
||||
\Count and show all years that don't have any 5-weekend months
|
||||
C:= 0;
|
||||
for Year:= 1900 to 2100 do
|
||||
[for I:= 0 to 6 do \for all the 31-day months...
|
||||
if WeekDay(Year, MonthTbl(I), 1) = 6 \Friday\ then
|
||||
I:= 10; \bail out of 'for' loop
|
||||
if I<10 then \'for' loop completed
|
||||
[if (C&$F) = 0 then CrLf(0); \(format 16 years per line)
|
||||
C:= C+1; \ without finding a 5-weekend
|
||||
IntOut(0, Year); ChOut(0, ^ ); \ so show the year
|
||||
];
|
||||
];
|
||||
CrLf(0); IntOut(0, C); CrLf(0); \show number of years
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue