Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
37
Task/Identity-matrix/PureBasic/identity-matrix.basic
Normal file
37
Task/Identity-matrix/PureBasic/identity-matrix.basic
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
>Procedure identityMatrix(Array i(2), size) ;valid only for size >= 0
|
||||
;formats array i() as an identity matrix of size x size
|
||||
Dim i(size - 1, size - 1)
|
||||
|
||||
Protected j
|
||||
For j = 0 To size - 1
|
||||
i(j, j) = 1
|
||||
Next
|
||||
EndProcedure
|
||||
|
||||
|
||||
Procedure displayMatrix(Array a(2))
|
||||
Protected rows = ArraySize(a(), 2), columns = ArraySize(a(), 1)
|
||||
Protected i, j
|
||||
|
||||
For i = 0 To rows
|
||||
For j = 0 To columns
|
||||
Print(RSet(Str(a(i, j)), 3, " "))
|
||||
Next
|
||||
PrintN("")
|
||||
Next
|
||||
EndProcedure
|
||||
|
||||
If OpenConsole()
|
||||
Dim i3(0, 0)
|
||||
Dim i4(0, 0)
|
||||
|
||||
identityMatrix(i3(), 3)
|
||||
identityMatrix(i4(), 4)
|
||||
|
||||
displayMatrix(i3())
|
||||
PrintN("")
|
||||
displayMatrix(i4())
|
||||
|
||||
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit"): Input()
|
||||
CloseConsole()
|
||||
EndIf
|
||||
Loading…
Add table
Add a link
Reference in a new issue