Write a program that fills the array a [1,, 10] with random numbers in the range from 0 to 10

Write a program that fills the array a [1,, 10] with random numbers in the range from 0 to 10, then swaps the first element with the maximum element. Display the original and resulting arrays.

If several elements of the array have the maximum value, then you can:

– swap only the first maximum element with the first element;

– assign all maximum elements to the value that had

the first element of the array.

program arr_max_1;

var a: array [1..10] of integer;

max, j: integer;

begin

j: = 1;

max: = 0;

randomize;

for i: integer: = 1 to 10 do

begin

a [i]: = random (11);

write (a [i]: 3);

if a [i]> max then

begin

max: = a [i];

j: = i;

end;

end;

a [j]: = a [1];

a [1]: = max;

writeln ();

// if only the first largest element needs to be changed, then
// the next one line can be deleted.

for i: integer: = j + 1 to 10 do if a [i] = max then a [i]: = a [j];

for i: integer: = 1 to 10 do write (a [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.