Write a program that fills the A (3,3) array from the keyboard with words of different sizes and replaces

Write a program that fills the A (3,3) array from the keyboard with words of different sizes and replaces the shortest word of the main diagonal with the longest word of the entire array. Display the original and resulting arrays.

program arr;
var a: array [1..3,1..3] of string;
//Max. and min. word length, indices max. element
max, min, imax, jmax: integer;
begin
max: = 1; min: = 100;
writeln (‘Enter 9 words’);

for i: = 1 to 3 do
for j: = 1 to 3 do
begin
readln (a [i, j]);
if length (a [i, j])> max then
begin
max: = length (a [i, j]); imax: = i; jmax: = j;
end;
if (length (a [i, j]) <min) and (i = j) then
begin
min: = length (a [i, j]);
end;
end;

for i: = 1 to 3 do
for j: = 1 to 3 do if j <3 then write (a [i, j]: 20)
else writeln (a [i, j]: 20);

writeln ();

for i: = 1 to 3 do
for j: = 1 to 3 do
begin
if (i = j) and (length (a [i, j]) = min) then a [i, j]: = a [imax, jmax];
if j <3 then write (a [i, j]: 20) else writeln (a [i, j]: 20);
end
end.

The program replaces all the shortest elements of the diagonal with the first largest element.



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.