var a: array[1..100] of real; i, n: integer; min, max: real; k: integer;
begin {ввод массива} if handsfree then n := random(20) + 5 else begin write('n = '); readln(n); end;
writeln('Данные массива:'); for i := 1 to n do begin if handsfree then begin a[i] := random(100); write(a[i], ' '); end else readln(a[i]); end; writeln();
{подсчет элементов} k := 0; for i := 1 to n do if a[i] > 5 then k := k + 1; writeln(k); end.
procedure MatrA(var a: mass); var i, j: integer; begin for i := 1 to n do for j := 1 to m do begin writeln('a[', i, ',', j, ']: '); readln(a[i, j]) end end;
procedure MatrB(var b: mass); var i, j: integer; begin for i := 1 to n1 do for j := 1 to m1 do begin writeln('b[', i, ',', j, ']: '); readln(b[i, j]) end end;
procedure Sum(a, b: mass; var c: mass); var i, j: integer; begin for i := 1 to n do for j := 1 to m do c[i, j] := a[i, j] + b[i, j]; end;
begin writeln('Введите n,m матрицы A'); readln(n, m); MatrA(a); writeln('Введите n,m матрицы B'); readln(n1, m1); MatrB(b); if (n1 <> n) and (m1 <> m) then writeln('Матрицы сложить нельзя') else begin Sum(a, b, c); writeln('A+B'); for i := 1 to n do begin for j := 1 to m do write(c[i, j]:1:3, ' '); writeln end end; readln; end.
handsfree = true;
var
a: array[1..100] of real;
i, n: integer;
min, max: real;
k: integer;
begin
{ввод массива}
if handsfree then
n := random(20) + 5
else begin
write('n = ');
readln(n);
end;
writeln('Данные массива:');
for i := 1 to n do
begin
if handsfree then begin
a[i] := random(100);
write(a[i], ' ');
end
else readln(a[i]);
end;
writeln();
{подсчет элементов}
k := 0;
for i := 1 to n do
if a[i] > 5 then k := k + 1;
writeln(k);
end.
mass = array[1..10, 1..10] of real;
var
a, b, c: mass;
n, m, i, j, n1, m1: integer;
procedure MatrA(var a: mass);
var
i, j: integer;
begin
for i := 1 to n do
for j := 1 to m do
begin
writeln('a[', i, ',', j, ']: ');
readln(a[i, j])
end
end;
procedure MatrB(var b: mass);
var
i, j: integer;
begin
for i := 1 to n1 do
for j := 1 to m1 do
begin
writeln('b[', i, ',', j, ']: ');
readln(b[i, j])
end
end;
procedure Sum(a, b: mass; var c: mass);
var
i, j: integer;
begin
for i := 1 to n do
for j := 1 to m do
c[i, j] := a[i, j] + b[i, j];
end;
begin
writeln('Введите n,m матрицы A');
readln(n, m);
MatrA(a);
writeln('Введите n,m матрицы B');
readln(n1, m1);
MatrB(b);
if (n1 <> n) and (m1 <> m) then
writeln('Матрицы сложить нельзя')
else begin
Sum(a, b, c);
writeln('A+B');
for i := 1 to n do
begin
for j := 1 to m do
write(c[i, j]:1:3, ' ');
writeln
end
end;
readln;
end.