1)
var
ar: array of integer;
n, min, max: integer;
begin
write('Введите размер массива:');
read(n);
setlength(ar, n);
if (n > 0) then
ar[0] := random(-10, 10);
min := ar[0];
max := ar[0];
write(ar[0]:4);
end;
for var i := 1 to n - 1 do
ar[i] := random(-10, 10);
if (ar[i] < min) then min := ar[i]
else if (ar[i] > max) then max := ar[i];
write(ar[i]:4);
writeln(#13#10 + 'Среднее геометрическое модулей минимального и максимального значений = ',
sqrt(abs(max) * abs(min)):5:5);
end.
2)
function minOrMax(ar: array of integer; size: integer; findMin: boolean): integer;
index: integer;
index := 0;
for var i := 1 to size - 1 do
if (findMin) and (ar[i] < ar[index]) then index := i
else if (not findMin) and (ar[i] > ar[index]) then index := i;
result := index;
3)
n: integer;
sqrt(abs(ar[minOrMax(ar, n, true)]) * abs(ar[minOrMax(ar, n, false)])):5:5);
4:
var a: array [1..3] of integer;
i,min,max : integer;
for i:= 1 to 3 do
write('a[',i,'] = ');
read(a[i]);
writeln;
min:= a[1];
max:= a[1];
if a[i] < min then
min:= a[i];
if a[i] > max then
max:= a[i];
writeln('min = ',min);
writeln('max = ',max);
5:
var a: array [1..5] of integer;
i,max : integer;
for i:= 1 to 5 do
1)
var
ar: array of integer;
n, min, max: integer;
begin
write('Введите размер массива:');
read(n);
setlength(ar, n);
if (n > 0) then
begin
ar[0] := random(-10, 10);
min := ar[0];
max := ar[0];
write(ar[0]:4);
end;
for var i := 1 to n - 1 do
begin
ar[i] := random(-10, 10);
if (ar[i] < min) then min := ar[i]
else if (ar[i] > max) then max := ar[i];
write(ar[i]:4);
end;
writeln(#13#10 + 'Среднее геометрическое модулей минимального и максимального значений = ',
sqrt(abs(max) * abs(min)):5:5);
end.
2)
function minOrMax(ar: array of integer; size: integer; findMin: boolean): integer;
var
index: integer;
begin
index := 0;
for var i := 1 to size - 1 do
if (findMin) and (ar[i] < ar[index]) then index := i
else if (not findMin) and (ar[i] > ar[index]) then index := i;
result := index;
end;
3)
function minOrMax(ar: array of integer; size: integer; findMin: boolean): integer;
var
index: integer;
begin
index := 0;
for var i := 1 to size - 1 do
if (findMin) and (ar[i] < ar[index]) then index := i
else if (not findMin) and (ar[i] > ar[index]) then index := i;
result := index;
end;
var
ar: array of integer;
n: integer;
begin
write('Введите размер массива:');
read(n);
setlength(ar, n);
if (n > 0) then
begin
ar[0] := random(-10, 10);
write(ar[0]:4);
end;
for var i := 1 to n - 1 do
begin
ar[i] := random(-10, 10);
write(ar[i]:4);
end;
writeln(#13#10 + 'Среднее геометрическое модулей минимального и максимального значений = ',
sqrt(abs(ar[minOrMax(ar, n, true)]) * abs(ar[minOrMax(ar, n, false)])):5:5);
end.
4:
var a: array [1..3] of integer;
i,min,max : integer;
begin
for i:= 1 to 3 do
begin
write('a[',i,'] = ');
read(a[i]);
writeln;
end;
min:= a[1];
max:= a[1];
for i:= 1 to 3 do
begin
if a[i] < min then
begin
min:= a[i];
end;
end;
for i:= 1 to 3 do
begin
if a[i] > max then
begin
max:= a[i];
end;
end;
writeln('min = ',min);
writeln('max = ',max);
end.
5:
var a: array [1..5] of integer;
i,max : integer;
begin
for i:= 1 to 5 do
begin
write('a[',i,'] = ');
read(a[i]);
writeln;
end;
max:= a[1];
for i:= 1 to 3 do
begin
if a[i] > max then
begin
max:= a[i];
end;
end;
writeln('max = ',max);
end.