Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
29
Task/Dot-product/Pascal-P/dot-product.pas
Normal file
29
Task/Dot-product/Pascal-P/dot-product.pas
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
program dotproduct(output);
|
||||
(* Dot product *)
|
||||
|
||||
const
|
||||
maxi = 2;
|
||||
|
||||
type
|
||||
realarray = array [0 .. maxi] of real;
|
||||
|
||||
var
|
||||
x, y: realarray;
|
||||
|
||||
function dotproduct(a, b: realarray): real;
|
||||
var
|
||||
i: integer;
|
||||
res: real;
|
||||
begin
|
||||
res := 0;
|
||||
for i := 0 to maxi do
|
||||
res := res + (a[i] * b[i]);
|
||||
dotproduct := res;
|
||||
end;
|
||||
|
||||
begin
|
||||
x[0] := 1; x[1] := 3; x[2] := -5;
|
||||
y[0] := 4; y[1] := -2; y[2] := -1;
|
||||
writeln(dotproduct(x, y));
|
||||
(* readln; *)
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue