program ComplessiEser;
var
zIn, zApp : Complex;
filegen : file of Complex;
op : char;
i, quanti : integer;
begin
repeat
writeln('che vuoi fare? [A/B/F]');
writeln(' A: scrivere su COMPL.DAT numeri complessi letti in input');
writeln(' B: stampare la somma dei numeri complessi letti da COMPL.DAT');
writeln(' F: per terminare');
readln(op);
case op of
'a', 'A' :
begin
assign(filegen, 'COMPL.DAT');
rewrite(filegen);
write('quanti complessi vuoi mettere? ');
readln(quanti);
for i := 1 to quanti do
begin
ReadComplex(zIn);
write(filegen, zIn)
end;
close(filegen)
end;
'b', 'B' :
begin
assign(filegen, 'COMPL.DAT');
reset(filegen);
AssegnaC(0, 0, zApp);
while not eof(filegen) do
begin
read(filegen, zIn);
SommaC(zApp, zIn, zApp);
end;
WriteComplex(zApp);
close(filegen)
end;
'f', 'F' : writeln('FINE');
else
writeln(' SCELTA SCORRETTA ')
end
until (op = 'F') or (op = 'f')
end.