The elements of the array a are cyclically shifted by 1 position to the left, and the first and last elements are swapped.

program arr;
const n = 40; // sets the number of elements in the array
var a: array [1..n] of integer;
temp: integer;
begin
randomize;
// Form the array
for i: integer: = 1 to n do
begin
a [i]: = random (30);
write (a [i]: 3);
end;
temp: = a [1];
writeln ();
// Shift the array
for i: integer: = 1 to n – 1 do a [i]: = a [i + 1];
a [n]: = temp; // first and last element is exchange of values
// display the array with a shift
for i: integer: = 1 to n 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.