Var a : array [1..5, 1..5] of integer; i, j : integer; begin randomize; for i := 1 to 5 do begin for j := 1 to 5 do begin a[i, j] := random (1000); write (a[i, j], ' '); end; writeln; end; for i := 1 to 5 do for j := 1 to 5 do if i > j then a[i, j] := 1 else if j > i then a[i, j] := 0; for i := 1 to 5 do begin for j := 1 to 5 do write (a[i, j], ' '); writeln; end; end.
var a : array [1..4, 1..5] of integer; i, j, m, c : integer; begin randomize; m := 1000; for i := 1 to 4 do begin for j := 1 to 5 do begin a[i, j] := random (1000); if a[i, j] < m then m := a[i, j]; write (a[i, j], ' '); end; writeln; end; c := 0; for i := 1 to 4 do for j := 1 to 5 do if a[i, j] = m then c := c + 1; writeln (m, ' ', c); end.
var a : array [1..4, 1..4] of integer; i, j, p : integer; begin randomize; for i := 1 to 4 do begin for j := 1 to 4 do begin a[i, j] := random (10); write (a[i, j], ' '); end; writeln; end; p := 1; for i := 1 to 4 do begin if a[i, i] <> 0 then p := p * a[i, i]; if a[i, 5 - i] <> 0 then p := p * a[i, 5 - i]; end; writeln (p); end.
// PascalABC.NET 3.2, сборка 1353 от 27.11.2016 // Внимание! Если программа не работает, обновите её версию!
begin var b:=MatrRandom(4,4,-5,5); b.Println(3); var p:=1; var s:=0; Write('Элементы главной диагонали: '); for var i:=0 to 3 do for var j:=0 to 3 do if i<j then p*=b[i,j] else if i>j then s+=b[i,j] else Write(b[i,j]:3); Writeln(Newline,'П=',p,', S=',s) end.
Пример -2 -1 -2 4 0 1 1 -3 0 1 5 5 3 4 3 2 Элементы главной диагонали: -2 1 5 2 П=-120, S=11
a : array [1..5, 1..5] of integer;
i, j : integer;
begin
randomize;
for i := 1 to 5 do
begin
for j := 1 to 5 do
begin
a[i, j] := random (1000);
write (a[i, j], ' ');
end;
writeln;
end;
for i := 1 to 5 do
for j := 1 to 5 do
if i > j then a[i, j] := 1
else if j > i then a[i, j] := 0;
for i := 1 to 5 do
begin
for j := 1 to 5 do
write (a[i, j], ' ');
writeln;
end;
end.
var
a : array [1..4, 1..5] of integer;
i, j, m, c : integer;
begin
randomize;
m := 1000;
for i := 1 to 4 do
begin
for j := 1 to 5 do
begin
a[i, j] := random (1000);
if a[i, j] < m then m := a[i, j];
write (a[i, j], ' ');
end;
writeln;
end;
c := 0;
for i := 1 to 4 do
for j := 1 to 5 do
if a[i, j] = m then
c := c + 1;
writeln (m, ' ', c);
end.
var
a : array [1..4, 1..4] of integer;
i, j, p : integer;
begin
randomize;
for i := 1 to 4 do
begin
for j := 1 to 4 do
begin
a[i, j] := random (10);
write (a[i, j], ' ');
end;
writeln;
end;
p := 1;
for i := 1 to 4 do
begin
if a[i, i] <> 0 then p := p * a[i, i];
if a[i, 5 - i] <> 0 then p := p * a[i, 5 - i];
end;
writeln (p);
end.
// Внимание! Если программа не работает, обновите её версию!
begin
var b:=MatrRandom(4,4,-5,5); b.Println(3);
var p:=1;
var s:=0;
Write('Элементы главной диагонали: ');
for var i:=0 to 3 do
for var j:=0 to 3 do
if i<j then p*=b[i,j]
else
if i>j then s+=b[i,j]
else Write(b[i,j]:3);
Writeln(Newline,'П=',p,', S=',s)
end.
Пример
-2 -1 -2 4
0 1 1 -3
0 1 5 5
3 4 3 2
Элементы главной диагонали: -2 1 5 2
П=-120, S=11