Hi,
Can anybody help my with how to make this declaration.
I want to make an array as a constant:
I have been looking in the extended Pascal ISO standard, and found some thing like this:
type
t = array [1..3] of integer;
const
c = t[1:1, 2:2, 3:3];
What I want is a constant called DaysInMonth[0..1, 1..12] with containing the number of days in the particular month, the first 0..1 is wheater it is a leap year or not.
program testconstarray;
type
monthtype = array [0..1, 1..12] of integer;
const
daysinmonth = monthtype[0:1:31, 0:2:28, 0:3:31, 0:4:30, 0:5:31, 0:6:30,
0:7:31, 0:8:31, 0:9:30, 0:10:31, 0:11:30, 0:12:31,
1:1:31, 1:2:29, 1:3:31, 1:4:30, 1:5:31, 1:6:30,
1:7:31, 1:8:31, 1:9:30, 1:10:31, 1:11:30, 1:12:31];
var
i: integer;
begin
for i := 1 to 12 do
begin
writeln('normal ', i, ' ', daysinmonth[0,i]);
end
writeln;
for i := 1 to 12 do
begin
writeln('leap ', i, ' ', daysinmonth[1,i]);
end;
end.
It does not work - is it possible at all or is there a trick?
klaus