-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP09.BAS
More file actions
49 lines (41 loc) · 764 Bytes
/
P09.BAS
File metadata and controls
49 lines (41 loc) · 764 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
DIM arows, acols AS INTEGER
DIM brows, bcols AS INTEGER
DIM r, c 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 arows <> brows OR acols <> bcols THEN
PRINT "ERROR: A size <> B size, cant sum!"
SYSTEM
END IF
DIM z(arows, acols) AS DOUBLE
FOR r = 1 TO arows
FOR c = 1 TO acols
z(r, c) = a(r, c) + b(r, c)
NEXT
NEXT
PRINT "Z ["; arows; "] ["; acols; "]:"
FOR r = 1 TO arows
FOR c = 1 TO acols
PRINT z(r, c),
NEXT
PRINT
NEXT