June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
20
Task/Dot-product/BASIC/dot-product-1.basic
Normal file
20
Task/Dot-product/BASIC/dot-product-1.basic
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
100 :
|
||||
110 REM DOT PRODUCT
|
||||
120 :
|
||||
130 REM INITIALIZE VECTORS OF LENGTH N
|
||||
140 N = 3
|
||||
150 DIM V1(N): DIM V2(N)
|
||||
160 FOR I = 1 TO N
|
||||
170 V1(I) = INT ( RND (1) * 20 - 9.5)
|
||||
180 V2(I) = INT ( RND (1) * 20 - 9.5)
|
||||
190 NEXT I
|
||||
300 :
|
||||
310 REM CALCULATE THE DOT PRODUCT
|
||||
320 :
|
||||
330 FOR I = 1 TO N:DP = DP + V1(I) * V2(I): NEXT I
|
||||
400 :
|
||||
410 REM DISPLAY RESULT
|
||||
420 :
|
||||
430 PRINT "[";: FOR I = 1 TO N: PRINT " ";V1(I);: NEXT I
|
||||
440 PRINT "] . [";: FOR I = 1 TO N: PRINT " ";V2(I);: NEXT I
|
||||
450 PRINT "] = ";DP
|
||||
7
Task/Dot-product/BASIC/dot-product-2.basic
Normal file
7
Task/Dot-product/BASIC/dot-product-2.basic
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
DIM vec1(2), vec2(2), dot(0)
|
||||
|
||||
vec1() = 1, 3, -5
|
||||
vec2() = 4, -2, -1
|
||||
|
||||
dot() = vec1() . vec2()
|
||||
PRINT "Result is "; dot(0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue