program raf105;
const
n = 4;
var
a: array[1..n,1..n] of integer;
i,j,max,sum: integer;
begin
for i:=1 to n do
begin
for j:=1 to n do
begin
a[i,j]:= random(-9,9); // Заполнение массива
write(a[i,j]:2,' '); // Вывод массива
if a[i,j] < 0 then
if max = 0 then
max:= a[i,j]
else
if max < a[i,j] then
max:= a[i,j];
if i = j then
sum:= sum + a[i,j];
end;
writeln;
end;
writeln('Максимальный среди отрицательных элементов: ',max);
writeln('Сумма элементов главной диагонали: ',sum);
end.
PascalABC
uses
crt,math;
var s:real; i,j,f:real; a:integer;
begin
writeln('vvedite 1 chislo ');readln(i);
writeln('vvedite 2 chislo ');readln(j);
writeln('vvedite 3 chislo ');readln(f);
s:=i;
if j<s then s:=j;
if f<s then s:=f;
if s<0 then
begin
if i<0 then inc(a);
if j<0 then inc(a);
if f<0 then inc(a);
writeln('kolichestvo otricatelnix ',a:2);
end
else
begin
if i>0 then i:=i*-1;
if j>0 then j:=i*-1;
if f>0 then f:=i*-1;
end;
writeln('min chislo ',s:2:0);
readln;
end.