home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_01_02
/
1n02037a
< prev
next >
Wrap
Text File
|
1990-07-09
|
898b
|
49 lines
const
JAN = 1; DEC = 12;
WEEKS_PER_MONTH = 6;
SUN = 1; SAT = 7;
type
monthly_calendar =
array [1..WEEKS_PER_MONTH, SUN..SAT] of integer;
annual_calendar
= array [JAN..DEC] of monthly_calendar;
{*
* write a monthly calendar
*}
procedure write_monthly(var cal : monthly_calendar);
var
d, 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, w, sum : integer;
begin
sum := 0;
for w := 1 to WEEKS_PER_MONTH do
for d := SUN + 1 to SAT - 1 do
if cal[w, d] > 0 then
sum := sum + 1;
monthly_week_days := sum;
end;
Listing 1 - Calendars in Pascal using Constants