Create a program in an array with N numbers, swap the maximum and minimum values.

min: = a [1];
max: = a [1];
for i: = 1 to n do
begin
if a [i]> max then begin max: = a [i]; imin: = i; end;
if a [i] <min then begin min: = a [i]; imax: = i; end;
end;
buf: = a [imin];
a [imin]: = a [imax];
a [imax]: = buf;
SECOND METHOD FOR EXECUTING THE PROGRAM:
Var
a: array [1..100] of integer;
i, n, imin, imax: byte;
min, max, buf: integer;
Begin
Randomize;
Write (‘number of elements:’);
Readln (n);
For i: = 1 to n do
begin
a [i]: = random (101) -50;
Write (a [i], ”);
end;
Writeln;
For i: = 1 to n do write (a [i], ”);
Readln
End.



One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.