Ответ:
const
N = 10;
var
a: array[1..N] of integer;
i, max1, max2, buff: byte;
begin
randomize;
for i:=1 to N do begin
a[i] := random(10);
write(a[i]:3);
end;
writeln;
if a[1] > a[2] then begin
max1 := 1;
max2 := 2;
end
else begin
max1 := 2;
max2 := 1;
for i:=3 to N do
if a[i] > a[max1] then begin
buff := max1;
max1 := i;
if a[buff] > a[max2] then
max2 := buff;
else
if a[i] > a[max2] then
max2 := i;
writeln(max1,' ', a[max1]);
writeln(max2,' ', a[max2]);
end.
Объяснение:
Copyright © 2025 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
const
N = 10;
var
a: array[1..N] of integer;
i, max1, max2, buff: byte;
begin
randomize;
for i:=1 to N do begin
a[i] := random(10);
write(a[i]:3);
end;
writeln;
if a[1] > a[2] then begin
max1 := 1;
max2 := 2;
end
else begin
max1 := 2;
max2 := 1;
end;
for i:=3 to N do
if a[i] > a[max1] then begin
buff := max1;
max1 := i;
if a[buff] > a[max2] then
max2 := buff;
end
else
if a[i] > a[max2] then
max2 := i;
writeln(max1,' ', a[max1]);
writeln(max2,' ', a[max2]);
end.
Объяснение: