Дана вещественная матрица размерности n*m. Вывести номера строк, содержащих больше положительных элементов чем отрицательных.
Решите пожалуйста на языке Pacal
Ответы
Ответ дал:
0
Program strok;
uses crt;
const
m=3;
n=4;
var i,j,pos,neg: integer;
a:array[1..n, 1..m] of real;
begin
for i:=1 to n do
for j:=1 to m do
read(a[i,j]);
for i:= 1 to n do begin
neg:= 0;
pos:= 0;
for j:= 1 to m do begin
if a[i,j] < 0 then Inc(neg)
else Inc(pos);
end;
if pos > neg then
Write(IntToStr(i),' ');
end;
ReadLn;
end.
uses crt;
const
m=3;
n=4;
var i,j,pos,neg: integer;
a:array[1..n, 1..m] of real;
begin
for i:=1 to n do
for j:=1 to m do
read(a[i,j]);
for i:= 1 to n do begin
neg:= 0;
pos:= 0;
for j:= 1 to m do begin
if a[i,j] < 0 then Inc(neg)
else Inc(pos);
end;
if pos > neg then
Write(IntToStr(i),' ');
end;
ReadLn;
end.
Ответ дал:
0
for i:=1 to 1 do
for j:=1 to 5 do
if a[i,j]>0 then inc(t);
if t>=3 then writeln('1');
end;
begin
for i:=2 to 2 do
for j:=1 to 5 do
if a[i,j]>0 then inc(k);
if k>=3 then writeln('2');
end;
begin
for i:=3 to 3 do
for j:=1 to 5 do
if a[i,j]>0 then inc(b);
if b>=3 then writeln('3');
end;
for j:=1 to 5 do
if a[i,j]>0 then inc(t);
if t>=3 then writeln('1');
end;
begin
for i:=2 to 2 do
for j:=1 to 5 do
if a[i,j]>0 then inc(k);
if k>=3 then writeln('2');
end;
begin
for i:=3 to 3 do
for j:=1 to 5 do
if a[i,j]>0 then inc(b);
if b>=3 then writeln('3');
end;
Вас заинтересует
2 года назад
2 года назад
8 лет назад
8 лет назад
10 лет назад
10 лет назад
10 лет назад