55 lines
1.1 KiB
Plaintext
55 lines
1.1 KiB
Plaintext
DataSection
|
|
Data.i 2,3 ;matrix a (#rows, #cols)
|
|
Data.i 1,2,3, 4,5,6 ;elements by row
|
|
|
|
Data.i 3,1 ;matrix b (#rows, #cols)
|
|
Data.i 1, 5, 9 ;elements by row
|
|
EndDataSection
|
|
|
|
Procedure displayMatrix(Array a(2), text.s)
|
|
Protected i, j
|
|
Protected columns = ArraySize(a(), 2), rows = ArraySize(a(), 1)
|
|
|
|
PrintN(text + ": (" + Str(rows + 1) + ", " + Str(columns + 1) + ")")
|
|
For i = 0 To rows
|
|
For j = 0 To columns
|
|
Print(LSet(Str(a(i, j)), 4, " "))
|
|
Next
|
|
PrintN("")
|
|
Next
|
|
PrintN("")
|
|
EndProcedure
|
|
|
|
Procedure loadMatrix(Array a(2))
|
|
Protected rows, columns, i, j
|
|
Read.i rows
|
|
Read.i columns
|
|
|
|
Dim a(rows - 1, columns - 1)
|
|
|
|
For i = 0 To rows - 1
|
|
For j = 0 To columns - 1
|
|
Read.i a(i, j)
|
|
Next
|
|
Next
|
|
EndProcedure
|
|
|
|
Dim a(0,0)
|
|
Dim b(0,0)
|
|
Dim c(0,0)
|
|
|
|
If OpenConsole()
|
|
loadMatrix(a()): displayMatrix(a(), "matrix a")
|
|
loadMatrix(b()): displayMatrix(b(), "matrix b")
|
|
|
|
If multiplyMatrix(a(), b(), c())
|
|
displayMatrix(c(), "product of a * b")
|
|
Else
|
|
PrintN("product of a * b is undefined")
|
|
EndIf
|
|
|
|
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit")
|
|
Input()
|
|
CloseConsole()
|
|
EndIf
|