Программа:
Pascal:
const arr: array[1..10] of integer = (-5, 2, 4, -6, 12, 10, -3, 12, 15, 2);
var max1, max2: integer;
begin
max1 := arr.max;
max2 := -MAXINT;
for var i := 1 to 10 do
if (arr[i] > max2) and (arr[i] <> max1) then max2 := arr[i];
writeln(arr, #10, max1 + max2);
end.
Программа:
Pascal:
const arr: array[1..10] of integer = (-5, 2, 4, -6, 12, 10, -3, 12, 15, 2);
var max1, max2: integer;
begin
max1 := arr.max;
max2 := -MAXINT;
for var i := 1 to 10 do
if (arr[i] > max2) and (arr[i] <> max1) then max2 := arr[i];
writeln(arr, #10, max1 + max2);
end.