Дан двухмерный массив 3x4 случайных целых чисел. преобразовать массив следующим образом: элементы > 10 заменить на разницу номера строки и столбца, элементы ∈ [-5; 5] заменить на n строки в квадрате. полученный массив вывести!
var a : array [1..3, 1..4] of integer; i, j : integer; begin for i := 1 to 3 do for j := 1 to 4 do a[i, j] := trunc (random (30)) - 10; for i := 1 to 3 do for j := 1 to 4 do if a[i, j] > 10 then a[i, j] := i - j; for i := 1 to 3 do for j := 1 to 4 do if (a[i, j] <= 5) and (a[i, j] >= -5) then a[i, j] := sqr (i); for i := 1 to 3 do begin for j := 1 to 4 do write (a[i, j]:4, ' '); writeln; end; readln; e
var
a : array [1..3, 1..4] of integer;
i, j : integer;
begin
for i := 1 to 3 do
for j := 1 to 4 do
a[i, j] := trunc (random (30)) - 10;
for i := 1 to 3 do
for j := 1 to 4 do
if a[i, j] > 10 then a[i, j] := i - j;
for i := 1 to 3 do
for j := 1 to 4 do
if (a[i, j] <= 5) and (a[i, j] >= -5) then a[i, j] := sqr (i);
for i := 1 to 3 do
begin
for j := 1 to 4 do write (a[i, j]:4, ' ');
writeln;
end;
readln;
e
program P1;
uses
crt;
var
A : array[1..3] of array [1..4] of longint;
i,j : integer;
begin
clrscr;
randomize;
writeln('Massiv : ');
for i := 1 to 3 do
begin
writeln('');
for j := 1 to 4 do
begin
A[i][j] := random(15)+random(5)-random(5);
write(A[i][j]:2,' ');
end;
end;
for i := 1 to 3 do
for j := 1 to 4 do
begin
if A[i][j] > 10 then
A[i][j] := i - j;
if (A[i][j] >= -5) and (A[i][j] <= 5) then
A[i][j] := sqr(i);
end;
writeln('');
writeln('');
writeln('Itogoviy massiv : ');
for i := 1 to 3 do
begin
writeln('');
for j := 1 to 4 do
begin
write(A[i][j]:2,' ');
end;
end;
readln;
readln;
end.