Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Identity-matrix/XBasic/identity-matrix.basic
Normal file
33
Task/Identity-matrix/XBasic/identity-matrix.basic
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
PROGRAM "Identity matrix"
|
||||
VERSION "0.0000"
|
||||
|
||||
DECLARE FUNCTION Entry ()
|
||||
|
||||
FUNCTION Entry ()
|
||||
DO
|
||||
n = SBYTE(INLINE$("Enter size of matrix: "))
|
||||
LOOP UNTIL n > 0
|
||||
|
||||
DIM identity[n, n] '' all zero by default
|
||||
|
||||
' enter 1s in diagonal elements
|
||||
FOR i = 1 TO n
|
||||
identity[i, i] = 1
|
||||
NEXT i
|
||||
|
||||
' print identity matrix if n < 40
|
||||
PRINT
|
||||
|
||||
IF n < 40 THEN
|
||||
FOR i = 1 TO n
|
||||
FOR j = 1 TO n
|
||||
PRINT identity[i, j];
|
||||
NEXT j
|
||||
PRINT
|
||||
NEXT i
|
||||
ELSE
|
||||
PRINT "Matrix is too big to display on 80 column console"
|
||||
END IF
|
||||
|
||||
END FUNCTION
|
||||
END PROGRAM
|
||||
Loading…
Add table
Add a link
Reference in a new issue