Smart pascal source code
var
az: array[-1..1] of Integer;
a: array[-3..- 1] of Integer;
procedure minusONE();
var
i: Integer;
begin
Writeln('minus one-based array');
for i := Low(az) to High(az) do
begin
az[i] := i;
Writeln(IntToStr(i));
end;
for i in az do
Writeln(i);
Writeln(az[-1]);
Writeln(az[0]);
Writeln(az[1]);
end;
procedure minusTWO()
var
i: Integer;
begin
Writeln('minus 3-based array');
for i := Low(a) to High(a) do
begin
a[i] := i;
Writeln(IntToStr(i));
end;
for i in a do
Writeln(i);
end;
begin
minusONE;
Writeln('-----');
minusTWO;
{
minus one-based array
-1,0,1
minus 3-based array
-3,2,1
}
var az = [0,0,0],
a = [0,0,0];
function minusTWO() {
var i = 0;
var a$1 = 0;
WriteLn("minus 3-based array");
for(i=-3;i<=(-1);i++) {
a[(i)+3] = i;
WriteLn(i.toString());
}
for(a$1=-3;a$1<=(-1);a$1++) {
i = a[(a$1)+3];
WriteLn(i);
}
};
function minusONE() {
var i$1 = 0;
var a$2 = 0;
WriteLn("minus one-based array");
for(i$1=-1;i$1<=1;i$1++) {
az[(i$1)+1] = i$1;
WriteLn(i$1.toString());
}
for(a$2=-1;a$2<=1;a$2++) {
i$1 = az[(a$2)+1];
WriteLn(i$1);
}
WriteLn(az[(-1)+1]);
WriteLn(az[(0)+1]);
WriteLn(az[(1)+1]);
};
minusONE(); // -1,0,1
WriteLn("------------------");
minusTWO(); // -3,2,1