-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP10.BAS
More file actions
53 lines (45 loc) · 810 Bytes
/
P10.BAS
File metadata and controls
53 lines (45 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
DIM arows, acols AS INTEGER
DIM brows, bcols AS INTEGER
DIM r, c, i, sum AS INTEGER
CLS
INPUT "A rows: ", arows
INPUT "A columns: ", acols
DIM a(arows, acols) AS DOUBLE
FOR r = 1 TO arows
FOR c = 1 TO acols
PRINT "A ["; r; "] ["; c; "]: ";
INPUT a(r, c)
NEXT
NEXT
PRINT
INPUT "B rows: ", brows
INPUT "B columns: ", bcols
DIM b(brows, bcols) AS DOUBLE
FOR r = 1 TO brows
FOR c = 1 TO bcols
PRINT "B ["; r; "] ["; c; "]: ";
INPUT b(r, c)
NEXT
NEXT
PRINT
IF acols <> brows THEN
PRINT "ERROR: A columns <> B rows, cant multiply!"
SYSTEM
END IF
DIM z(arows, bcols) AS DOUBLE
FOR r = 1 TO arows
FOR c = 1 TO bcols
sum = 0
FOR i = 1 TO acols
sum = sum + a(r, i) * b(i, c)
NEXT
z(r, c) = sum
NEXT
NEXT
PRINT "Z ["; arows; "] ["; bcols; "]:"
FOR r = 1 TO arows
FOR c = 1 TO bcols
PRINT z(r, c),
NEXT
PRINT
NEXT