You are given a one-dimensional array of 10 integers. Find the largest and smallest

You are given a one-dimensional array of 10 integers. Find the largest and smallest difference between two adjacent elements and indicate the numbers of these elements.

program zz1;

const n = 10; // set the number of elements in the array

var i, max1, min, i1, i2, j1, j2: integer; // set variables of integer type

m: array [1..n] of integer;

begin

for i: = 1 to n do // write numbers in the array at random

m [i]: = random (21);

for i: = 1 to n do // display the array on the screen

write (m [i], ”);

writeln; // go to a new line to display the response

max1: = 0;

for i: = 1 to n-1 do // find the maximum element

if m [i] -m [i + 1]> max1 then begin max1: = m [i] -m [i + 1]; i1: = i; i2: = i + 1; end;

min: = 1,000,000; // set the initial value for the minimum element

for i: = 1 to n-1 do // organize a loop in which we iterate over all the numbers in the array

if m [i] -m [i + 1] <min then begin min: = m [i] -m [i + 1]; j1: = i; j2: = i + 1; end;

writeln (‘maximum difference between neighbors =’, max1, ‘numbers of neighbors’, i1, ”, i2); // display the answer

write (‘minimum difference between neighbors =’, min, ‘numbers of neighbors’, j1, ”, j2);

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.