RosettaCodeData/Task/Identity-matrix/BBC-BASIC/identity-matrix.basic

18 lines
375 B
Plaintext

INPUT "Enter size of matrix: " size%
PROCidentitymatrix(size%, im())
FOR r% = 0 TO size%-1
FOR c% = 0 TO size%-1
PRINT im(r%, c%),;
NEXT
PRINT
NEXT r%
END
DEF PROCidentitymatrix(s%, RETURN m())
LOCAL i%
DIM m(s%-1, s%-1)
FOR i% = 0 TO s%-1
m(i%,i%) = 1
NEXT
ENDPROC