const n=6;
var
p:array[1..n,1..n] of real;
i,j:integer;
begin
Randomize;
writeln('Исходный массив:');
for i:=1 to n do
begin
for j:=1 to n do
begin
p[i,j]:=10*random-5;
write(p[i,j]:6:1);
end;
writeln;
end;
for i:=1 to n do begin
for j:=1 to i-1 do p[i,j]:=round(p[i,j]);
for j:=i+1 to n do p[i,j]:=0;
end;
writeln('Полученный массив:');
for i:=1 to n do
begin
for j:=1 to n do write(p[i,j]:6:1);
writeln;
end;
end.
Пример:
Исходный массив:
-1.8 4.9 -1.2 3.2 1.9 -2.0
4.5 4.9 4.8 -0.6 -2.5 1.2
2.3 0.3 1.1 0.3 -3.0 2.5
1.7 -0.5 2.2 -3.6 -3.6 -4.4
-0.4 -4.7 1.9 -3.8 -0.7 0.1
-4.4 -3.2 -4.5 -4.8 1.5 3.4
Полученный массив:
-1.8 0.0 0.0 0.0 0.0 0.0
5.0 4.9 0.0 0.0 0.0 0.0
2.0 0.0 1.1 0.0 0.0 0.0
2.0 -1.0 2.0 -3.6 0.0 0.0
0.0 -5.0 2.0 -4.0 -0.7 0.0
-4.0 -3.0 -5.0 -5.0 1.0 3.4