StruktoPas Voorbeeld
1
2
3
{--------------------------------------------}
{ Proefwerk (11-12-2006) }
{ StruktoPas 1.0 (C) Sichemsoft NL }
{--------------------------------------------}
PROGRAM Proefwerk(input, output, cijfers);
TYPE _cijfers_record =
RECORD
naam : string;
cijfer : real;
END;
ArrayType1 = ARRAY [1..10] OF string;
ArrayType2 = ARRAY [1..10] OF real;
VAR cijfers : FILE OF _cijfers_record;
_cijfers : _cijfers_record;
totaal : real;
aantal : integer;
index : integer;
leerling : ArrayType1;
score : ArrayType2;
max : real;
{--------------------------------------------}
Procedure RunTimeError;
BEGIN
IF ExitCode <> 0 THEN
BEGIN
writeln('Runtime error: ',ExitCode);
readln;
END;
END;
{--------------------------------------------}
PROCEDURE verwerk_cijfers(VAR t:real; VAR a:integer; VAR i:integer);
BEGIN
a := 0;
t := 0;
max := 0;
i := 0;
WHILE NOT eof(cijfers) DO
BEGIN
read(cijfers, _cijfers);
a := a + 1;
leerling[a] := _cijfers.naam;
score[a] := _cijfers.cijfer;
t := t + _cijfers.cijfer;
IF _cijfers.cijfer > max THEN
BEGIN
max := _cijfers.cijfer;
i := a;
END;
END;
END;
{ proefwerkcijfers analyse }
{ bestandsindeling: }
{--------------------------------------------}
BEGIN
ExitProc := @RunTimeError;
Assign(cijfers, 'cijfers.fil');
reset(cijfers);
verwerk_cijfers(totaal, aantal, index);
writeln('gemiddelde over ', aantal, ' leerlingen: ', totaal / aantal : 5 : 2);
writeln('beste resultaat: ', leerling[index], ' ', score[index] : 4 : 1);
Close(cijfers);
readln; {*}
END.
{--------------------------------------------}