Enter an array of 5 elements from the keyboard, find the maximum and minimum elements and their numbers in it.

If there are several maximum or minimum elements, the program displays their numbers.

program min_max;
var a: array [1..5] of integer;
max, min: integer;
begin
writeln (‘Enter 5 array elements separated by a space’);
readln (a [1], a [2], a [3], a [4], a [5]);
max: = 1;
min: = 1;
for i: integer: = 1 to 4 do
begin
if a [max] <a [i + 1] then max: = i + 1;
if a [min]> a [i + 1] then min: = i + 1;
end;
writeln (‘Max. item =’, a [max]: 4);
writeln (‘Min. item =’, a [min]: 4);
Write (‘Max. Element number:’);
For i: integer: = 1 to 5 do if a [max] = a [i] then write (i: 3);
writeln ();
Write (‘Min. Element number:’);
For i: integer: = 1 to 5 do if a [min] = a [i] then write (i: 3);
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.