つづき(真理値表、ベン図)
DEF Bit(x,m)=MOD(INT(x/2^m),2) !mビット目を得る 0,1
SUB TruthTable(m$, N,T()) !真理値表ビットパターン(m$)から真理値表へ MAT T=ZER FOR j=0 TO N-1 PRINT " ";CHR$(j+ORD("A")); NEXT j PRINT " | f" PRINT "-------+----" FOR i=1 TO 2^N FOR j=0 TO N-1 !ビットパターン PRINT " ";STR$(Bit(i-1,N-j-1)); NEXT j PRINT " | "; LET T(i)=VAL(m$(i:i)) !値 PRINT T(i) NEXT i END SUB
DEF co(t)=r*COS(RAD(t)) !配置位置 DEF si(t)=r*SIN(RAD(t))
SUB Venn(m$) !真理値表ビットパターンからベン図へ(Venn's Diagram) ※3変数 SET WINDOW -1.5,1.5,-1.5,1.5 !表示領域 SET LINE width 2 PLOT LINES: -1,-1; 1,-1; 1,1; -1,1; -1,-1 !U LET r=0.35 DRAW circle WITH SHIFT(co(90),si(90)) !A DRAW circle WITH SHIFT(co(210),si(210)) !B DRAW circle WITH SHIFT(co(330),si(330)) !C DATA 0.9, 0.9 !A'B'C'の位置 DATA 0.35,-0.2 !A'B'C DATA -0.35,-0.2 !A'B C' DATA 0,-0.35 !A'B C DATA 0, 0.35 !A B'C' DATA 0.25, 0.15 !A B'C DATA -0.25, 0.15 !A B C' DATA 0, 0 !A B C SET AREA COLOR 4 FOR i=1 TO 2^N READ x,y IF VAL(m$(i:i))=1 THEN flood x,y !塗りつぶし NEXT i SET TEXT HEIGHT 0.2 !記号を書く SET TEXT JUSTIFY "center","half" SET TEXT background "opaque" PLOT TEXT ,AT -0.8,1: "U" LET r=0.85 PLOT TEXT ,AT co(90),si(90): "A" PLOT TEXT ,AT co(210),si(210): "B" PLOT TEXT ,AT co(330),si(330): "C" END SUB PICTURE circle !半径1/2の円 FOR i=0 TO 360 PLOT LINES: COS(RAD(i))/2,SIN(RAD(i))/2; NEXT i PLOT LINES END PICTURE
|