Const n=10; var a:array[1..n] of real; max,min:real; i:integer; begin Randomize; for i:=1 to n do begin a[i]:=10*random; write(a[i]:5:1); end; writeln; max:=a[1]; min:=a[1]; for i:=2 to n do begin if a[i]>max then max:=a[i]; if a[i]<min then min:=a[i]; end; writeln('max = ',max:4:1,' min = ',min:4:1); end.
Пример: 3.1 7.4 3.9 2.4 3.1 7.5 1.1 4.1 7.3 9.9 max = 9.9 min = 1.1
var a:array[1..n] of real;
max,min:real; i:integer;
begin
Randomize;
for i:=1 to n do begin
a[i]:=10*random;
write(a[i]:5:1);
end;
writeln;
max:=a[1];
min:=a[1];
for i:=2 to n do
begin
if a[i]>max then max:=a[i];
if a[i]<min then min:=a[i];
end;
writeln('max = ',max:4:1,' min = ',min:4:1);
end.
Пример:
3.1 7.4 3.9 2.4 3.1 7.5 1.1 4.1 7.3 9.9
max = 9.9 min = 1.1
begin
var a:=readARRreal('Вводите: ', readinteger('Кол-во элементов: '));
print ('Min:', a.min, '; max:', a.max);
end.