Var ar:array[1..30] of integer; i,max,max2,maxp,maxi:integer; begin; randomize; writeln('Array'); for i:=1 to 30 do begin; ar[i]:=random(1,100); write(ar[i]:4); end; for i:=1 to 30 do if max<ar[i] then begin; maxp:=max; max:=ar[i]; maxi:=i; end; ar[maxi]:=maxp; for i:=1 to 30 do if max2<ar[i] then max2:=ar[i]; writeln; writeln('Max1:',max); writeln('Max2:',max2); end.
i,max,max2,maxp,maxi:integer;
begin;
randomize;
writeln('Array');
for i:=1 to 30 do
begin;
ar[i]:=random(1,100);
write(ar[i]:4);
end;
for i:=1 to 30 do
if max<ar[i] then
begin;
maxp:=max;
max:=ar[i];
maxi:=i;
end;
ar[maxi]:=maxp;
for i:=1 to 30 do
if max2<ar[i] then max2:=ar[i];
writeln;
writeln('Max1:',max);
writeln('Max2:',max2);
end.