{ (c) David Vajda }
{ 10/03/25 }
{ Pascal Hash Excersize Program }
program pashash(input,output);
{ hier musste ich mir ein wenig wieder ins gedaechtnis rufen }
{ const, type, var ... das ist die richtige art und weise, variablen, ... zu definieren}
const
tMinIndex = 1;
tMaxIndex = 10;
type
tIndex = tMinIndex .. tMaxIndex;
tFeld = array [tIndex] of ShortInt;
var
X: tFeld = (2, 87, 16, 41, 76, 65, 33, 91, 7, 32);
i: tIndex;
m: ShortInt;
b: ShortInt;
function pashash (X: tFeld; n: tIndex; m: ShortInt; b: ShortInt): ShortInt;
var
i: tIndex;
y: ShortInt = 0;
begin
for i := tMinIndex to tMaxIndex do
begin
y := (b * X[i] + y) mod m;
end;
pashash := y;
end;
begin
writeln ('(c) David Vajda');
writeln ('10/03/25');
writeln ('Pascal Hash Excersize Program');
write ('X = (');
for i := tMinIndex to tMaxIndex do
begin
write (X[i], ', ')
end;
writeln (X[i], ')');
writeln ('base=64,m=97,hashval=', pashash(X,tMaxIndex,97,64));
writeln ('base=100,m=97,hashval=', pashash(X,tMaxIndex,97,100));
end.