# Сумма, произведение и т.п.

Посмотреть архив целиком
program matriza;

{\$APPTYPE CONSOLE}

uses
SysUtils;
var a:array[1..10,1..15] of integer;
b,nec:array[1..150] of integer;
i,j,n,m:integer;
sum,k:integer;
min,max,nmin,nstrmin,nmax,nstrmax,buf:integer;
l:integer;
t,proizv:integer;

begin
writeln('Vvedite kolichestvo strok');
writeln('Vvedite kolichestvo stolbvoz');
writeln('Vvedite matrizu');
for i:=1 to n do begin
for j:=1 to m do read (a[i,j]);
end;

{symma i kolichestvo otrizatelnix elementov, novii massiv s nimi}
k:=0;
sum:=0;
for i:=1 to n do
for j:=1 to m do
if a[i,j]<0 then begin
k:=k+1;
b[k]:=a[i,j];
sum:=sum+a[i,j];
end;

if k=0 then writeln ('Net otrizatelnix elementov')
else begin writeln ('Otrizatelnie elementi');
for i:=1 to k do write (b[i],' ');
writeln;
writeln('kolichestvo otrizatelnix elementov ravno ',k,' ,ix summa ravna ',sum);
end;

{pomeniat mestami pervii minimalnii i poslednii maksimalnii}
min:=a[1,1];
nmin:=1;
nstrmin:=1;
for i:=1 to n do
for j:=1 to m do
if a[i,j] nstrmin:=i;
nmin:=j;
min:=a[i,j];
end;
writeln('Pervii minimalnii element ',min,' stoit v ',nstrmin,' stroke, v ',nmin,' stolbze');

max:=a[1,1];
nmax:=1;
nstrmax:=1;
for i:=1 to n do
for j:=1 to m do
if a[i,j]>=max then begin
nstrmax:=i;
nmax:=j;
max:=a[i,j];
end;
writeln('Posledii maksimalnii element ',max,' stoit v ',nstrmax,' stroke, v ',nmax,' stolbze');

buf:=a[nstrmax,nmax];
a[nstrmax,nmax]:=a[nstrmin,nmin];
a[nstrmin,nmin]:=buf;

writeln('Izmenennaya matriza');
for i:=1 to n do begin
for j:=1 to m do write(a[i,j],' ');
writeln;
end;

{kolichestvo necetnix elementov}
l:=0;
for i:=1 to n do
for j:=1 to m do
if (a[i,j] mod 2=1) or (a[i,j] mod 2=-1) then begin
l:=l+1;
nec[l]:=a[i,j];
end;
if l=0 then writeln ('Net nechetnix chisel')
else writeln ('Nechetnie chisla');
for i:=1 to l do write (nec[i],' ');
writeln;

{proizvedenie polozitelnix elementov}
t:=0;
proizv:=1;
for i:=1 to n do
for j:=1 to m do
if a[i,j]>0 then begin
t:=t+1;
proizv:=proizv*a[i,j];
end;
if (proizv=1) and (t=0) then writeln('Net polozitelnix elementov dlia naxogdenia proizvedenia')
else writeln('Proizvedenie ravno ',proizv)