Найти суммы каждой строки матрицы



Дана матрица целых чисел. Найти суммы элементов каждой строки матрицы.

 

Program sumstrok;

const n=4;m=4;

var

    A:array [1..n,1..m] of integer;

    sum,i,j:integer;

begin

writeln;

writeln(’Vvedite elementy massiva:’);

for i:=1 to n do

   for j:=1 to m do

      read(A[i,j]);

writeln();

sum:=0;

for i:=1 to n do

 begin

   for j:=1 to m do sum:=sum+a[i,j];

   writeln(sum);

   sum:=0;

 end;

readln;

end.

Теги: , , , ,

Сравнить количество четных и нечетных чисел



Дана матрица целых чисел. Найти, каких чисел в этой матрице больше — четных или нечетных.

 

Program Chetnie;

const n=4;m=4;

var

    A:array [1..n,1..m] of integer;

    chet,nechet,i,j:integer;

begin

chet:=0;

nechet:=0;

writeln;

writeln(’Vvedite elementy massiva:’);

for i:=1 to n do

   for j:=1 to m do

    begin

      read(A[i,j]);

      if a[i,j] mod 2 = 0 then chet:=chet+1

         else nechet:=nechet+1;

    end;

if chet>nechet then writeln(’Chetnih bolshe’);

if chet<nechet then writeln(’Nechetnih bolshe’);

if chet=nechet then writeln(’Rovno’);

readln;

end.

Теги: , , ,