uses crt;
const nmax=15;
var a:array[1..nmax,1..nmax] of real;
b:array[1..nmax] of real;
n,i,j:integer;
s:real;
begin
clrscr;
randomize;
repeat
write('Размер матрицы до ',nmax,' n=');
readln(n);
until n in [1..nmax];
writeln('Исходная матрица:');
s:=0;
for i:=1 to n do
begin
for j:=1 to n do
begin
a[i,j]:=10*random;
write(a[i,j]:5:2);
if j=i then
begin
b[i]:=a[i,j];
s:=s+b[i];
end;
end;
writeln;
end;
writeln;
writeln('Массив элементов главной диагонали:');
for i:=1 to n do
write(b[i]:5:2);
writeln;
writeln('След=',s:0:2);
writeln('Преобразованная матрица:');
for i:=1 to n do
begin
for j:=1 to n do
begin
if i mod 2=0 then a[i,j]:=a[i,j]/s;
write(a[i,j]:5:2);
end;
writeln;
end;
readln
end.
const nmax=15;
var a:array[1..nmax,1..nmax] of real;
b:array[1..nmax] of real;
n,i,j:integer;
s:real;
begin
clrscr;
randomize;
repeat
write('Размер матрицы до ',nmax,' n=');
readln(n);
until n in [1..nmax];
writeln('Исходная матрица:');
s:=0;
for i:=1 to n do
begin
for j:=1 to n do
begin
a[i,j]:=10*random;
write(a[i,j]:5:2);
if j=i then
begin
b[i]:=a[i,j];
s:=s+b[i];
end;
end;
writeln;
end;
writeln;
writeln('Массив элементов главной диагонали:');
for i:=1 to n do
write(b[i]:5:2);
writeln;
writeln('След=',s:0:2);
writeln('Преобразованная матрица:');
for i:=1 to n do
begin
for j:=1 to n do
begin
if i mod 2=0 then a[i,j]:=a[i,j]/s;
write(a[i,j]:5:2);
end;
writeln;
end;
readln
end.