var
n,max,min,i:integer;
a:array of integer;
begin
readln(n);
setlength(a,n);
max:=0; min:=0;
for i:=0 to n-1 do
readln(a[i]);
if a[i]>a[max] then
max:=i
else
if a[i]<=a[min] then
min:=i;
end;
i:=a[max];
a[max]:=a[min];
a[min]:=i;
write(a[i]:4);
end.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
var
n,max,min,i:integer;
a:array of integer;
begin
readln(n);
setlength(a,n);
max:=0; min:=0;
for i:=0 to n-1 do
begin
readln(a[i]);
if a[i]>a[max] then
max:=i
else
if a[i]<=a[min] then
min:=i;
end;
i:=a[max];
a[max]:=a[min];
a[min]:=i;
for i:=0 to n-1 do
write(a[i]:4);
end.