Program sashka9595; uses crt; const n=20; var a:array[1..n] of integer; max,i,j,k: integer; begin writeln('*** alphaues is thinking... ***'); writeln('*** OK ***'); randomize; writeln('Массив: '); for i:=1 to n do begin a[i]:=random(100)-50; write(a[i],' '); end; for i:=1 to 3 do begin k:=i; max:=a[i]; for j:=i+1 to n do if a[j]>max then begin max:=a[j]; k:=j; end; a[k]:=a[i]; a[i]:=max; end; writeln(); writeln('Три наибольших элемента массива:'); for i:=1 to 3 do writeln(i,'-й: ',a[i]); end.
Program sashka9595;
uses crt;
const n=20;
var
a:array[1..n] of integer;
max,i,j,k: integer;
begin
writeln('*** alphaues is thinking... ***');
writeln('*** OK ***');
randomize;
writeln('Массив: ');
for i:=1 to n do
begin
a[i]:=random(100)-50;
write(a[i],' ');
end;
for i:=1 to 3 do
begin
k:=i;
max:=a[i];
for j:=i+1 to n do
if a[j]>max then
begin
max:=a[j];
k:=j;
end;
a[k]:=a[i];
a[i]:=max;
end;
writeln();
writeln('Три наибольших элемента массива:');
for i:=1 to 3 do
writeln(i,'-й: ',a[i]);
end.