Const nmax=100;
var a,b:array[1..nmax] of integer;
i,j,n1,n2,s:integer;
p:boolean;
begin
randomize;
repeat
write('Размер массива A = ');
readln(n1);
until n1 in [1..nmax];
writeln;
writeln('Массив A: ');
for i:=1 to n1 do
begin
a[i]:=random(15);
write(a[i],' ');
end;
writeln;
writeln;
repeat
write('Размер массива B = ');
readln(n2);
until n2 in [1..nmax];
writeln;
writeln('Массив B: ');
for i:=1 to n2 do
begin
b[i]:=random(15);
write(b[i], ' ');
end;
s:=0;
for i:=1 to n1 do
begin
p:=false;
j:=1;
while (j<=n2) and not p do <br>if b[j]=a[i] then p:=true
else
inc(j);
if p then inc(s,a[i]);
end;
writeln;
writeln;
writeln('Сумма = ',s);
end.