Описать функцию sum(A,S1,S2),вычисляющую сумму тех элементов матрицы А, номера строк и столбцов, которых принадлежат соответственно непустым множествам*S1*и*S2*типа ном — Pascal(Паскаль)

const n=10;
type номер=1..n;
матрица=array [номер,*номер]*of*real;
ном*=*set*of*номер;

const n=10;
type
nomer=1..n;
matr=array[nomer,nomer] of real;
nom=set of nomer;
function Sum(a:matr;s1,s2:nom):real;
var i,j:byte;
    sm:real;
begin
sm:=0;
for i:=1 to n do
for j:=1 to n do
if (i in s1)and(j in s2)then
sm:=sm+a[i,j];
Sum:=sm;
end;

Leave a Comment

5 + 5 =