Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Identity-matrix/OoRexx/identity-matrix.rexx
Normal file
29
Task/Identity-matrix/OoRexx/identity-matrix.rexx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
say "a 3x3 identity matrix"
|
||||
say
|
||||
call printMatrix createIdentityMatrix(3)
|
||||
say
|
||||
say "a 5x5 identity matrix"
|
||||
say
|
||||
call printMatrix createIdentityMatrix(5)
|
||||
|
||||
::routine createIdentityMatrix
|
||||
use arg size
|
||||
matrix = .array~new(size, size)
|
||||
loop i = 1 to size
|
||||
loop j = 1 to size
|
||||
if i == j then matrix[i, j] = 1
|
||||
else matrix[i, j] = 0
|
||||
end j
|
||||
end i
|
||||
return matrix
|
||||
|
||||
::routine printMatrix
|
||||
use arg matrix
|
||||
|
||||
loop i = 1 to matrix~dimension(1)
|
||||
line = ""
|
||||
loop j = 1 to matrix~dimension(2)
|
||||
line = line matrix[i, j]
|
||||
end j
|
||||
say line
|
||||
end i
|
||||
Loading…
Add table
Add a link
Reference in a new issue