определить количество положительных элементов каждого столбца матрицы X=(x1k) и прописать их в один массив m(m1,m2...mk)
Answers & Comments
Nobunaga
Var ma:array of array of integer; ar:array of integer; i,k,j,n,m:integer; begin; randomize; readln(n); readln(m); k:=0; setlength(ar,m+1); setlength(ma,n+1); for i:=1 to n do setlength(ma[i],m+1); writeln('Matrix:'); for i:=1 to n do begin; writeln; for j:=1 to m do begin; ma[i,j]:=random(21)-10; write(ma[i,j]:4); end; end; for i:=1 to m do begin; for j:=1 to n do if ma[j,i]>0 then inc(k); ar[i]:=k; k:=0; end; writeln; writeln('Final array:'); for i:=1 to m do write(ar[i]:4); end.
Answers & Comments
ar:array of integer;
i,k,j,n,m:integer;
begin;
randomize;
readln(n);
readln(m);
k:=0;
setlength(ar,m+1);
setlength(ma,n+1);
for i:=1 to n do
setlength(ma[i],m+1);
writeln('Matrix:');
for i:=1 to n do
begin;
writeln;
for j:=1 to m do
begin;
ma[i,j]:=random(21)-10;
write(ma[i,j]:4);
end;
end;
for i:=1 to m do
begin;
for j:=1 to n do
if ma[j,i]>0 then inc(k);
ar[i]:=k;
k:=0;
end;
writeln;
writeln('Final array:');
for i:=1 to m do
write(ar[i]:4);
end.