var A: array [1 .. MAX, 1 .. MAX] of integer; i, j, N: byte;
begin randomize; write(' Введите N(макс. ', MAX, ') = '); readln(N); writeln(' Исходная матрица: '); for i := 1 to N do begin for j := 1 to N do begin A[i, j] := random(100) - 50; write(A[i, j]:6); end; writeln; end;
writeln(' Замена: '); for i := 1 to N do begin for j := 1 to N do begin if A[i, j] < 0 then A[i, j] := 0; if A[i, j] > 0 then A[i, j] := 1; write(A[i, j]:2); end; writeln; end;
writeln; writeln(' Нижняя треугольная матрица: '); for i := 1 to N do begin for j := 1 to N do if i > j then write(A[i, j]:2); writeln; end; end.
Answers & Comments
MAX = 100;
var
A: array [1 .. MAX, 1 .. MAX] of integer;
i, j, N: byte;
begin
randomize;
write(' Введите N(макс. ', MAX, ') = ');
readln(N);
writeln(' Исходная матрица: ');
for i := 1 to N do
begin
for j := 1 to N do
begin
A[i, j] := random(100) - 50;
write(A[i, j]:6);
end;
writeln;
end;
writeln(' Замена: ');
for i := 1 to N do
begin
for j := 1 to N do
begin
if A[i, j] < 0 then A[i, j] := 0;
if A[i, j] > 0 then A[i, j] := 1;
write(A[i, j]:2);
end;
writeln;
end;
writeln;
writeln(' Нижняя треугольная матрица: ');
for i := 1 to N do
begin
for j := 1 to N do
if i > j then
write(A[i, j]:2);
writeln;
end;
end.