home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_01_02
/
1n02037b
< prev
next >
Wrap
Text File
|
1990-07-09
|
1KB
|
56 lines
----------
const
WEEKS_PER_MONTH = 6;
type
month = (JAN, FEB, MAR, APR, MAY, JUN,
JUL, AUG, SEP, OCT, NOV, DEC);
day = (SUN, MON, TUE, WED, THU, FRI, SAT);
type
monthly_calendar =
array [1..WEEKS_PER_MONTH, day] of integer;
annual_calendar
= array [month] of monthly_calendar;
{*
* write a monthly calendar
*}
procedure write_monthly(var cal : monthly_calendar);
var
d : day
w : integer;
begin
for w := 1 to WEEKS_PER_MONTH do
begin
for d := SUN to SAT do
if cal[w, d] > 0 then
write(cal[w, d]:4)
else
write(' ':4);
writeln;
end;
end;
{*
* return the number of week days in a month
*}
function monthly_week_days(var cal : monthly_calendar)
: integer;
var
d : day;
w, sum : integer;
begin
sum := 0;
for w := 1 to WEEKS_PER_MONTH do
for d := MON to FRI do
if cal[w, d] > 0 then
sum := sum + 1;
monthly_week_days := sum;
end;
Listing 2 - Calendars in Pascal using Enumerations