Const
n=10;
var
a,b:array[1..n] of real;
s,s2,s3:real;
i:integer;
begin
Randomize;
Write('A: ');
s2:=0;
for i:=1 to n do begin
a[i]:=Random(51)-20;
Write(a[i],' ');
s2:=s2+sqr(a[i])
end;
Writeln;
Write('B: ');
s:=0; s3:=0;
for i:=1 to n do begin
b[i]:=Random(51)-20;
Write(b[i],' ');
s3:=s3+sqr(b[i]);
s:=s+a[i]*b[i]
end;
Writeln;
Writeln('cos(A)=',s/sqrt(s2*s3))
end.
Тестовое решение:
A: 23 -16 24 30 -17 9 -15 -7 23 19
B: -18 1 -18 -1 -8 -5 -16 8 14 -9
cos(A)=-0.206955416562861