|
MathMLを使用してWebブラウザー上で数式を美麗に表示します。
#4281
行列の掛け算式をWebブラウザー上で表示させます。
LET NN=4
LET MM=3
PUBLIC STRING A$(10,26,26),X$(26,26),SS$
DIM A(MM+1)
LET S$="abcdefghijklmnopqrstuvwxyz"
OPEN #1:NAME "行列掛け算.html"
ERASE #1
PRINT #1:"<!DOCTYPE html>"
PRINT #1:"<html>"
PRINT #1:"<head>"
PRINT #1:" <title>行列掛け算</title>"
PRINT #1:" <script async src=";CHR$(34);"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML";CHR$(34);"></script>"
PRINT #1:"</head>"
PRINT #1:"<body>"
PRINT #1:"<h1>行列掛け算</h1>"
FOR M=1 TO MM
FOR I=1 TO NN
FOR J=1 TO NN
LET A$(M,I,J)="<msub><mi>"&S$(M:M)&"</mi><mn>"&STR$(I)&STR$(J)&"</mn></msub>"
NEXT J
NEXT I
NEXT M
FOR I=2 TO NN
FOR P=2 TO MM
PRINT #1:"<math>"
CALL RECURSIVE(1,P+1,I,A)
FOR M=1 TO P
PRINT #1:"<mfenced>"
PRINT #1:"<mtable>"
FOR J=1 TO I
PRINT #1:"<mtr>"
FOR K=1 TO I-1
PRINT #1:"<mtd>"
PRINT #1:A$(M,J,K)
PRINT #1:"</mtd>"
NEXT K
PRINT #1:"<mtd>"
PRINT #1:A$(M,J,I)
PRINT #1:"</mtd>"
PRINT #1:"</mtr>"
NEXT J
PRINT #1:"</mtable>"
PRINT #1:"</mfenced>"
NEXT M
PRINT #1:"</math>"
PRINT #1:CHR$(60);CHR$(98);CHR$(114);CHR$(62)
PRINT #1:"<math>"
PRINT #1:"<mo>=</mo>"
CALL DISPLAY(I,X$,#1)
PRINT #1:"</math>"
PRINT #1:CHR$(60);CHR$(98);CHR$(114);CHR$(62)
PRINT #1:CHR$(60);CHR$(98);CHR$(114);CHR$(62)
PRINT #1:CHR$(60);CHR$(98);CHR$(114);CHR$(62)
NEXT P
NEXT I
PRINT #1:"</body>"
PRINT #1:"</html>"
CLOSE #1
END
EXTERNAL SUB RECURSIVE(NN,N,M,A())
IF N<NN THEN
LET SS$=SS$&"<mo>+</mo><mi>"&A$(1,A(1),A(3))&"</mi>"
FOR J=2 TO N-2
LET SS$=SS$&"<mi>"&A$(J,A(J+1),A(J+2))&"</mi>"
NEXT J
LET SS$=SS$&"<mi>"&A$(N-1,A(N),A(2))&"</mi>"
LET FL=0
FOR J=3 TO N
IF A(J)<>M THEN LET FL=1
NEXT J
IF FL=0 THEN
LET SS$(1:10)=""
LET X$(A(1),A(2))=SS$
LET SS$=""
END IF
ELSE
FOR I=1 TO M
LET A(NN)=I
CALL RECURSIVE(NN+1,N,M,A)
NEXT I
END IF
END SUB
EXTERNAL SUB DISPLAY(N,P$(,),#1)
PRINT #1:"<mfenced>"
PRINT #1:"<mtable>"
FOR I=1 TO N
PRINT #1:"<mtr>"
FOR J=1 TO N-1
PRINT #1:"<mtd>"
PRINT #1:P$(I,J)
PRINT #1:"</mtd>"
NEXT J
PRINT #1:"<mtd>"
PRINT #1:P$(I,N)
PRINT #1:"</mtd>"
PRINT #1:"</mtr>"
NEXT I
PRINT #1:"</mtable>"
PRINT #1:"</mfenced>"
END SUB
|
|