Var n,i:integer; a,max,min:real; begin write('n = '); readln(n); readln(a); max:=a; min:=a; for i:=1 to n-1 do begin readln(a); if a>max then max:=a; if a<min then min:=a; end; writeln('max = ',max:4:1,' min = ',min:4:1); end.
Пример: n = 5 8.4 2.7 3.0 9.1 4.8 max = 9.1 min = 2.7
begin
write('n = ');
readln(n);
readln(a);
max:=a; min:=a;
for i:=1 to n-1 do
begin
readln(a);
if a>max then max:=a;
if a<min then min:=a;
end;
writeln('max = ',max:4:1,' min = ',min:4:1);
end.
Пример:
n = 5
8.4
2.7
3.0
9.1
4.8
max = 9.1 min = 2.7