Ответ:
program ricardomilos;
var massiv: array [1..10] of integer; i, count, min, minold, imin, imax, max, maxold, minoldtwo, mintwo, maxoldtwo, maxtwo: integer; checkmax, checkmin: boolean;
begin
Randomize();
checkmin := false;
checkmax := false;
count := 0;
for i := 1 to 10 do begin
if i = 1 then minold := massiv[i];
if i = 1 then maxold := massiv[i];
massiv[i] := Random(-10, 10);
min := massiv[i];
max := massiv[i];
if min < minold then begin minold := min; imin := i; end;
if max > maxold then begin maxold := max; imax := i; end;
if massiv[i] mod 2 = 0 then count += 1;
end;
for i := 1 to 10 do
if i <> imin then begin
if checkmin = false then minoldtwo := massiv[i];
checkmin := true;
mintwo := massiv[i];
if mintwo < minoldtwo then minoldtwo := mintwo;
if i <> imax then begin
if checkmax = false then maxoldtwo := massiv[i];
checkmax := true;
maxtwo := massiv[i];
if maxtwo > maxoldtwo then maxoldtwo := maxtwo;
Writeln('Количество четных элементов: ', count);
Writeln('Минимальный элемент: ', minold);
Writeln('Сумма 2 максимума и 2 минимума: ', minoldtwo + maxoldtwo);
end.
Объяснение:
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
program ricardomilos;
var massiv: array [1..10] of integer; i, count, min, minold, imin, imax, max, maxold, minoldtwo, mintwo, maxoldtwo, maxtwo: integer; checkmax, checkmin: boolean;
begin
Randomize();
checkmin := false;
checkmax := false;
count := 0;
for i := 1 to 10 do begin
if i = 1 then minold := massiv[i];
if i = 1 then maxold := massiv[i];
massiv[i] := Random(-10, 10);
min := massiv[i];
max := massiv[i];
if min < minold then begin minold := min; imin := i; end;
if max > maxold then begin maxold := max; imax := i; end;
if massiv[i] mod 2 = 0 then count += 1;
end;
for i := 1 to 10 do
begin
if i <> imin then begin
if checkmin = false then minoldtwo := massiv[i];
checkmin := true;
mintwo := massiv[i];
if mintwo < minoldtwo then minoldtwo := mintwo;
end;
if i <> imax then begin
if checkmax = false then maxoldtwo := massiv[i];
checkmax := true;
maxtwo := massiv[i];
if maxtwo > maxoldtwo then maxoldtwo := maxtwo;
end;
end;
Writeln('Количество четных элементов: ', count);
Writeln('Минимальный элемент: ', minold);
Writeln('Сумма 2 максимума и 2 минимума: ', minoldtwo + maxoldtwo);
end.
Объяснение: