June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
25
Task/Dot-product/Modula-2/dot-product.mod2
Normal file
25
Task/Dot-product/Modula-2/dot-product.mod2
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
MODULE DotProduct;
|
||||
FROM RealStr IMPORT RealToStr;
|
||||
FROM Terminal IMPORT WriteString,WriteLn,ReadChar;
|
||||
|
||||
TYPE Vector =
|
||||
RECORD
|
||||
x,y,z : REAL
|
||||
END;
|
||||
|
||||
PROCEDURE DotProduct(u,v : Vector) : REAL;
|
||||
BEGIN
|
||||
RETURN u.x*v.x + u.y*v.y + u.z*v.z
|
||||
END DotProduct;
|
||||
|
||||
VAR
|
||||
buf : ARRAY[0..63] OF CHAR;
|
||||
dp : REAL;
|
||||
BEGIN
|
||||
dp := DotProduct(Vector{1.0,3.0,-5.0},Vector{4.0,-2.0,-1.0});
|
||||
RealToStr(dp, buf);
|
||||
WriteString(buf);
|
||||
WriteLn;
|
||||
|
||||
ReadChar
|
||||
END DotProduct.
|
||||
Loading…
Add table
Add a link
Reference in a new issue