¡á¤³¤³¤«¤é¡á
option character kanji
input prompt "Á´³Ñ¤Ç£±Ê¸»úÆþÎϤ·¤Æ¤¯¤À¤µ¤¤:":a$
let b=ord(a$)
let b$=str$(b)
let c$=bstr$(ord(a$),16)
let d$=right$(c$,2)&left$(c$,2)
print
print chr$(bval(c$,16))&"(JIS:"&c$&")"&" -> "&chr$(bval(d$,16))&"(JIS:"&d$&")"
end
¡á¤³¤³¤Þ¤Ç¡á
ͱ¡¢Îã³°¤¬½Ð¤ëʸ»úÈÖÃϤò°ìÍ÷¤¹¤ë¤â¤Î½ñ¤¤¤Æ¤ß¤Þ¤·¤¿¡£
¡á¤³¤³¤«¤é¡á
rem -- Á´³Ñʸ»ú¤Î»ÏÅÀ:8481 (2121) / ½ªÃ¼:38700 (972C) --
rem -- ·ë²Ì½ÐÎϤϲèÌÌɽ¼¨¤è¤ê¥Õ¥¡¥¤¥ë¤Ë½ñ¤½Ð¤·¤¿Êý¤¬Áᤤ¤«¤â --
option arithmetic decimal
option character kanji
do
input prompt "¤É¤³¤«¤é¸«¤ë?(Ⱦ³Ñ»ÏÅÀ=1,Á´³Ñ»ÏÅÀ=2)":start
if start=1 or start=2 then
exit do
elseif start=0 then
stop
else
end if
loop
select case start
case is =2
let start=8481
case else
end select
for count=start to 38700 step 1
let hcount$=bstr$(count,16)
let strcount$=str$(count)
when exception in
print chr$(39)+chr$(count)+chr$(39)+" chr$("+strcount$+") <-> JIS ["+hcount$+"]"
use
print chr$(7)+"Îã³°"+str$(extype)+chr$(7)+" chr$("+strcount$+") <-> JIS ["+hcount$+"]"
end when
next count
end
¡á¤³¤³¤Þ¤Ç¡á
Windows XP (Windows2000) ¤Ïʸ»ú¥³¡¼¥É¤¬¥æ¥Ë¥³¡¼¥É¤ËÊѹ¹¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¥·¥Õ¥ÈJIS¤Îʸ»ú¤Ï¥æ¥Ë¥³¡¼¥É¤ËÊÑ´¹¤µ¤ì¤Æɽ¼¨¤µ¤ì¤Þ¤¹¡£
¥·¥Õ¥ÈJIS¤ÈJIS¤ÎÂбþ¤Ï¡¤°ì±þ¡¤°ìÂаì¤È¤ß¤Ê¤»¤Þ¤¹¤¬¡¤
¥æ¥Ë¥³¡¼¥É¤ÈJIS¡Ê¤¢¤ë¤¤¤Ï¥·¥Õ¥ÈJIS¡Ë¤È¤ÎÂбþ¤Ï°ìÂаì¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£
¥·¥Õ¥ÈJIS¢ª¥æ¥Ë¥³¡¼¥É¢ª¥·¥Õ¥ÈJIS¤ÈÊÑ´¹¤¹¤ë¤È¸µ¤ËÌá¤é¤Ê¤¤¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£
½½¿ÊBASIC¤Î¾ì¹ç¡¤¥Õ¥¡¥¤¥ëÆþ½ÐÎϤϥ·¥Õ¥ÈJIS¤Ê¤Î¤Ç¡¤
²èÌ̤Ëɽ¼¨¤·¤¿Ê¸»ú¤ò¥¯¥ê¥Ã¥×¥Ü¡¼¥É·Ðͳ¤Ç¼è¤ê½Ð¤¹¤Î¤Ç¤Ê¤¯¡¤
¥Õ¥¡¥¤¥ë¤Ë½ñ¤½Ð¤·¤¿Ê¸»ú¤òÂоݤˤ¹¤ì¤Ð¡¤ÌäÂê¤Ïµ¯¤³¤ê¤Ë¤¯¤¯¤Ê¤ë¤È»×¤¤¤Þ¤¹¡£
100 OPTION CHARACTER KANJI
110 INPUT PROMPT "Á´³Ñ¤Ç£±Ê¸»úÆþÎϤ·¤Æ¤¯¤À¤µ¤¤:":a$
120 LET b=ORD(a$)
130 LET b$=STR$(b)
140 LET c$=BSTR$(ORD(a$),16)
150 LET d$=right$(c$,2)&left$(c$,2)
160 PRINT
170 PRINT CHR$(BVAL(c$,16))&"(JIS:"&c$&")"&" -> "&CHR$(BVAL(d$,16))&"(JIS:"&d$&")"
180 OPEN #1:NAME "A:TEST.TXT"
190 ERASE #1
200 PRINT #1:CHR$(BVAL(d$,16))
210 CLOSE #1
220 OPEN #2:NAME "A:TEST.TXT"
230 INPUT #2:s$
240 CLOSE #2
250 PRINT BSTR$(ORD(s$),16)
260 END
100 OPTION ARITHMETIC DECIMAL
110 OPTION CHARACTER KANJI
120 FOR hi=BVAL("21",16) TO BVAL("73",16)
130 FOR lo=BVAL("21",16) TO BVAL("7E",16)
140 LET count=hi*256+lo
150 LET hcount$=BSTR$(count,16)
160 LET strcount$=STR$(count)
170 WHEN EXCEPTION IN
180 PRINT
CHR$(39)&CHR$(count)&CHR$(39)&" chr$("&strcount$&")
<-> JIS ["&hcount$&"]"
190 USE
200 PRINT
CHR$(7)&"Îã³°"&STR$(EXTYPE)&CHR$(7)&"
chr$("&strcount$&") <-> JIS ["&hcount$&"]"
210 END WHEN
220 NEXT lo
230 NEXT hi
240 END
FUNCTION GCD(a,b) !ºÇÂç¸øÌó¿ô
IF b=0 THEN LET GCD=a ELSE LET GCD=GCD(b, MOD(a,b))
END FUNCTION
LET r1=8 !¸ÇÄê±ß¤ÎȾ·Â
LET r2=5 !Æ°¤¯±ß¤ÎȾ·Â¡¡¢¨r1*r2>0¤Ê¤éÆ⦡¢r1*r2<0¤Ê¤é³°Â¦
LET r3=4 !ÅÀP¤Î°ÌÃÖ¡ÊÆ°¤¯±ß¤ÎÃæ¿´¤«¤é¡Ë¡¡¢¨r3=r2¤Ê¤é¥µ¥¤¥¯¥í¥¤¥É¡¢r3¡âr2¤Ê¤é¥È¥í¥³¥¤¥É
IF r1*r2>0 THEN
LET sz=ABS(r1)+ABS(r3)+1
ELSE
LET sz=ABS(r1)+ABS(r2)+ABS(r3)+1
END IF
SET WINDOW -sz,sz,-sz,sz !ɽ¼¨Îΰè
DRAW grid !ºÂɸ
DRAW circle WITH SCALE(r1) !Â礤ʱß
LET iter=r2/GCD(r1,r2) !¼þ²ó¿ô
FOR th=0 TO 360*iter !STEP 0.2 !¢¨Á¤ˤʤë¤Ê¤éÄ´À°
DRAW p WITH ROTATE(r1/r2*RAD(th))*SHIFT(r1-r2,0)*ROTATE(-RAD(th)) !ÅÀP
NEXT th
PICTURE p !¸¶ÅÀ¡ÊÆ°¤¯±ß¤ÎÃæ¿´¡Ë¤ò´ð½à¤ËÅÀP¤òÉÁ¤¯
DRAW disk WITH SCALE(0.1)*SHIFT(r3,0) !ÅÀP
END PICTURE
FUNCTION GCD(a,b) !ºÇÂç¸øÌó¿ô
IF b=0 THEN LET GCD=a ELSE LET GCD=GCD(b, MOD(a,b))
END FUNCTION
LET r1=8 !¸ÇÄê±ß¤ÎȾ·Â
LET r2=5 !Æ°¤¯±ß¤ÎȾ·Â¡¡¢¨r1*r2>0¤Ê¤éÆ⦡¢r1*r2<0¤Ê¤é³°Â¦
LET r3=4 !ÅÀP¤Î°ÌÃÖ¡ÊÆ°¤¯±ß¤ÎÃæ¿´¤«¤é¡Ë¡¡¢¨r3=r2¤Ê¤é¥µ¥¤¥¯¥í¥¤¥É¡¢r3¡âr2¤Ê¤é¥È¥í¥³¥¤¥É
IF r1*r2>0 THEN
IF ABS(r1)>ABS(r2) THEN
LET sz=MAX(ABS(r1),ABS(r1-r2)+ABS(r3))+1
ELSE
LET sz=ABS(r1)+ABS(r3)+1
END IF
ELSE
LET sz=ABS(r1)+ABS(r2)+ABS(r3)+1
END IF
SET WINDOW -sz,sz,-sz,sz !ɽ¼¨Îΰè
DRAW grid !ºÂɸ
DRAW circle WITH SCALE(r1) !Â礤ʱß
LET iter=r2/GCD(r1,r2) !¼þ²ó¿ô
SET DRAW MODE NOTXOR
DIM w(4,4) !¥í¡¼¥«¥ëºÂɸ¤ò¥ï¡¼¥ë¥ÉºÂɸ¤ËÊÑ´¹¤¹¤ë
MAT w=SHIFT(r1-r2,0) !£±¤ÄÁ°
DRAW p(0) WITH w
FOR th=0 TO 360*iter !STEP 0.2 !¢¨Á¤ˤʤë¤Ê¤éÄ´À°
DRAW p(0) WITH w !£±¤ÄÁ°¤ò¾Ã¤¹
MAT w=ROTATE(-r1/r2*RAD(th)) * SHIFT(r1-r2,0)*ROTATE(RAD(th)) !»ÑÀª¤È°ÌÃÖ
DRAW p(1) WITH w !¥ï¡¼¥ë¥ÉºÂɸ¤Ë¡¢Æ°¤¯±ß¤ÈÅÀP¤òÉÁ¤¯
WAIT DELAY 0.02
NEXT th
PICTURE p(f) !¥í¡¼¥«¥ëºÂɸ¤Î¸¶ÅÀ¤ò´ð½à¤Ë¡¢Æ°¤¯±ß¤ÈÅÀP¤òÉÁ¤¯
IF f=1 THEN !ÉÁ²è½ç¤ò¹Íθ¤·¤Æ¡¢Àè¤ËÅÀP¤òÉÁ¤¯
SET DRAW MODE OVERWRITE !ÉÁ²èdisk¤ËNOTXOR¤òÈ¿±Ç¤µ¤»¤Ê¤¤
DRAW disk WITH SCALE(0.2)*SHIFT(r3,0)
SET DRAW MODE NOTXOR
END IF
DRAW circle WITH SCALE(r2) !Æ°¤¯±ß
PLOT LINES: 0,0; r3,0
END PICTURE
REM ** ²èÁü½Ì¾®ÊäÀµ¥×¥í¥°¥é¥à **
OPTION ARITHMETIC NATIVE
DECLARE EXTERNAL SUB revision1,revision2
GLOAD "C:\Program Files\Decimal BASIC\BASICw32\SAMPLE\ZENKOUJI.JPG"
LET px0=PIXELX(1)
LET py0=PIXELY(1)
SET WINDOW 0,px0,0,py0
DIM pict0(0 TO px0,0 TO py0) ! ¸µ²èÁü(ÇÛÎó¤Î²¼¸Â¤Ï0°Ê³°¤â²Ä)
SET COLOR MODE "NATIVE"
ASK PIXEL ARRAY (0,py0) pict0 ! ¸µ²èÁü¤Î¿§»Øɸ
DO
LET err=0
INPUT PROMPT "[½Ì¾®Î¨ÆþÎÏ] ʬ»Ò,ʬÊì (ʬ»Ò=1 or ʬ»Ò=ʬÊì-1)" : num,denom
IF num<1 OR INT(num)<>num THEN LET err=1
IF denom<2 OR INT(denom)<>denom THEN LET err=1
IF num<>1 AND num<>denom-1 THEN LET err=1
LOOP UNTIL err=0
LET t0=TIME
LET kk=num/denom ! ½Ì¾®Î¨
MAT PLOT CELLS, IN px0-px0*kk,py0*kk ; px0,0 : pict0 !! ÊäÀµ¤Ê¤·
!
LET px9=INT(SIZE(pict0,1)*kk+0.00001)-1 ! k=1/3,3*k<>1¤ËÂбþ
LET py9=INT(SIZE(pict0,2)*kk+0.00001)-1
DIM pict9(0 TO px9,0 TO py9) ! ½Ì¾®ÊäÀµ²èÁü(ÇÛÎó¤Î²¼¸Â¤Ï0)
IF num=1 THEN
CALL revision1(pict0,pict9,denom) ! ½Ì¾®Î¨=1/n
ELSE
CALL revision2(pict0,pict9,denom) ! ½Ì¾®Î¨=(n-1)/n
END IF
IF TIME-t0<0.2 THEN WAIT DELAY 0.2
BEEP
SET TEXT COLOR "RED"
SET TEXT HEIGHT py0/30
PLOT TEXT ,AT 1,1 : "PUSH ANY KEY"
DO
FOR i=8 TO 239
IF GetKeyState(i)<0 THEN EXIT DO
NEXT i
LOOP
MAT PLOT CELLS, IN 0,py9 ; px9,0 : pict9 !! ÊäÀµ¤¢¤ê
BEEP
END
REM ½Ì¾®Î¨=1/n (1/2,1/3,1/4,...)
EXTERNAL SUB revision1(sp0(,),sp9(,),k)
OPTION ARITHMETIC NATIVE
LET kk=1/k
DIM c9(3)
LET lx0=LBOUND(sp0,1)
LET ly0=LBOUND(sp0,2)
LET ux0=UBOUND(sp0,1)
LET uy0=UBOUND(sp0,2)
LET ux9=UBOUND(sp9,1)
LET uy9=UBOUND(sp9,2)
FOR i=lx0 TO ux0-(k-1) STEP k
FOR j=ly0 TO uy0-(k-1) STEP k
MAT c9=ZER
FOR ii=0 TO k-1
FOR jj=0 TO k-1
CALL acm(i+ii,j+jj)
NEXT jj
NEXT ii
LET sp9((i-lx0)*kk,(j-ly0)*kk)=COLORINDEX(c9(1)/k^2,c9(2)/k^2,c9(3)/k^2)
NEXT j
NEXT i
LET rm2=MOD(uy0,k) ! ±ï(²£)¤Î½èÍý
IF rm2<>k-1 THEN
FOR i=lx0 TO ux0-(k-1) STEP k
MAT c9=ZER
FOR j=0 TO rm2
CALL acm(i,uy0-j)
NEXT j
LET sp9((i-lx0)*kk,uy9)=COLORINDEX(c9(1)/(rm2+1),c9(2)/(rm2+1),c9(3)/(rm2+1))
NEXT i
END IF
LET rm1=MOD(ux0,k) ! ±ï(½Ä)¤Î½èÍý
IF rm1<>k-1 THEN
FOR j=ly0 TO uy0-(k-1) STEP k
MAT c9=ZER
FOR i=0 TO rm1
CALL acm(ux0-i,j)
NEXT i
LET sp9(ux9,(j-ly0)*kk)=COLORINDEX(c9(1)/(rm1+1),c9(2)/(rm1+1),c9(3)/(rm1+1))
NEXT j
END IF
IF rm1<>k-1 OR rm2<>k-1 THEN ! ³Ñ¤Î½èÍý
MAT c9=ZER
FOR i=0 TO rm1
FOR j=0 TO rm2
CALL acm(ux0-i,uy0-j)
NEXT j
NEXT i
LET rm12=(rm1+1)*(rm2+1)
LET sp9(ux9,uy9)=COLORINDEX(c9(1)/rm12,c9(2)/rm12,c9(3)/rm12)
END IF
SUB acm(x0,y0)
ASK COLOR MIX(sp0(x0,y0)) b,g,r
LET c9(1)=c9(1)+b
LET c9(2)=c9(2)+g
LET c9(3)=c9(3)+r
END SUB
END SUB
REM ½Ì¾®Î¨=(n-1)/n (2/3,3/4,4/5,...)
EXTERNAL SUB revision2(sp0(,),sp9(,),k)
OPTION ARITHMETIC NATIVE
DECLARE FUNCTION c_ave
LET kk=(k-1)/k
LET num1=(k-1)-1
LET lx0=LBOUND(sp0,1)
LET ly0=LBOUND(sp0,2)
LET ux0=UBOUND(sp0,1)
LET uy0=UBOUND(sp0,2)
LET ux9=UBOUND(sp9,1)
LET uy9=UBOUND(sp9,2)
FOR i=lx0 TO ux0-k STEP k
FOR j=ly0 TO uy0-k STEP k
CALL center
CALL side1(i,j,1,0)
CALL side1(i+k,j,-1,num1)
CALL side2(i,j,1,0)
CALL side2(i,j+k,-1,num1)
CALL corner(i,j,1,1,0,0)
CALL corner(i,j+k,1,-1,0,num1)
CALL corner(i+k,j,-1,1,num1,0)
CALL corner(i+k,j+k,-1,-1,num1,num1)
NEXT j
NEXT i
LET x8=(i-lx0-k)*kk+num1
LET y8=(j-ly0-k)*kk+num1
IF uy9<>y8 THEN CALL edge1
IF ux9<>x8 THEN CALL edge2
IF ux9<>x8 AND uy9<>y8 THEN CALL edge_corner
FUNCTION c_ave(c1,c2) ! ¿§¶¯ÅٲýÅÊ¿¶Ñ
ASK COLOR MIX(c1) b1,g1,r1
ASK COLOR MIX(c2) b2,g2,r2
LET c_ave=COLORINDEX((b1+2*b2)/3,(g1+2*g2)/3,(r1+2*r2)/3)
END FUNCTION
SUB center
FOR ii=2 TO num1
FOR jj=2 TO num1
LET sp9((i-lx0)*kk+ii-1,(j-ly0)*kk+jj-1)=sp0(i+ii,j+jj)
NEXT jj
NEXT ii
END SUB
SUB side1(x,y,ii,m)
FOR jj=2 TO num1
LET sp9((i-lx0)*kk+m,(j-ly0)*kk+jj-1)=c_ave(sp0(x,y+jj),sp0(x+ii,y+jj))
NEXT jj
END SUB
SUB side2(x,y,jj,n)
FOR ii=2 TO num1
LET sp9((i-lx0)*kk+ii-1,(j-ly0)*kk+n)=c_ave(sp0(x+ii,y),sp0(x+ii,y+jj))
NEXT ii
END SUB
SUB corner(x,y,ii,jj,m,n)
ASK COLOR MIX(sp0(x,y)) b1,g1,r1
ASK COLOR MIX(sp0(x,y+jj)) b2,g2,r2
ASK COLOR MIX(sp0(x+ii,y)) b3,g3,r3
ASK COLOR MIX(sp0(x+ii,y+jj)) b4,g4,r4
LET bb=(b1+2*b2+2*b3+4*b4)/9
LET gg=(g1+2*g2+2*g3+4*g4)/9
LET rr=(r1+2*r2+2*r3+4*r4)/9
LET sp9((i-lx0)*kk+m,(j-ly0)*kk+n)=COLORINDEX(bb,gg,rr)
END SUB
SUB edge1
FOR i=lx0 TO ux0-k STEP k ! ²¼ÊդνèÍý
FOR ii=0 TO num1
FOR jj=0 TO uy9-y8-2
LET sp9((i-lx0)*kk+ii,uy9-jj)=sp0(i+ii+1,uy0-jj)
NEXT jj
LET sp9((i-lx0)*kk+ii,uy9-jj)=c_ave(sp0(i+ii+1,uy0-(jj+1)),sp0(i+ii+1,uy0-jj))
NEXT ii
NEXT i
END SUB
SUB edge2
FOR j=ly0 TO uy0-k STEP k ! ±¦ÊդνèÍý
FOR jj=0 TO num1
FOR ii=0 TO ux9-x8-2
LET sp9(ux9-ii,(j-ly0)*kk+jj)=sp0(ux0-ii,j+jj+1)
NEXT ii
LET sp9(ux9-ii,(j-ly0)*kk+jj)=c_ave(sp0(ux0-(ii+1),j+jj+1),sp0(ux0-ii,j+jj+1))
NEXT jj
NEXT j
END SUB
SUB edge_corner
FOR ii=ux9 TO x8+1 STEP-1
FOR jj=uy9 TO y8+1 STEP-1
LET sp9(ii,jj)=sp0(ux0-(ux9-ii),uy0-(uy9-jj))
NEXT jj
NEXT ii
END SUB
END SUB
FUNCTION phi(k,i,N) !´ðÄì´Ø¿ô¦Õk(i)
IF k=0 THEN
LET phi=1/SQR(N)
ELSE
LET phi=SQR(2/N)*COS((2*i+1)*k*PI/(2*N))
END IF
END FUNCTION
SUB DCT(f(,),TBL(,),iTBL(,), FF(,)) !DCTÊÑ´¹
MAT FF=TBL*f
MAT FF=FF*iTBL !F(k,l)=¦²[j=0,N-1]¦²[i=0,N-1]f(i,j)*¦Õk(i)*¦Õl(j)
END SUB
SUB iDCT(FF(,),TBL(,),iTBL(,), f(,)) !DCTµÕÊÑ´¹
MAT f=iTBL*FF
MAT f=f*TBL !f(i,j)=¦²[l=0,N-1]¦²[k=0,N-1]F(k,l)*¦Õk(i)*¦Õl(j)
END SUB
DIM TBLn(0 TO N-1,0 TO N-1) !ÊÑ´¹¹ÔÎó T
MAT TBLn=ZER
FOR k=0 TO N-1 !N¡ßN¥Ö¥í¥Ã¥¯¤Î¦Õk(i)¤Î¥Æ¡¼¥Ö¥ë¤ò¤Ä¤¯¤ë
FOR i=0 TO N-1
LET TBLn(k,i)=phi(k,i,N)
NEXT i
NEXT k
!!!MAT PRINT TBLn;
DIM iTBLn(N,N) !¢¨T^-1=T^t¡¢¢è¥æ¥Ë¥¿¥ê¡¼¹ÔÎó
MAT iTBLn=TRN(TBLn)
!-------------------- ¤³¤³¤Þ¤Ç¤¬¥µ¥Ö¥ë¡¼¥Á¥ó
SET COLOR MODE "NATIVE"
!GLOAD "c:\BASICw32\SAMPLE\ZENKOUJI.JPG" !²èÁü¤òÆɤ߹þ¤à
GLOAD "c:\My Documents\test2.bmp" !²èÁü¤òÆɤ߹þ¤à
ASK PIXEL SIZE (0,0; 1,1) w,h !²èÁü¤Î½Ä²£¤ÎÂ礤µ(¥Ô¥¯¥»¥ëñ°Ì)¤òÄ´¤Ù¤ë
DIM p(w,h) !²èÁü¤ÎÂ礤µ¤ËÂбþ¤¹¤ëÇÛÎóÍ×ÁǤòÍÑ°Õ¤¹¤ë
ASK PIXEL ARRAY (0,1) p !²èÁü¤Î³ÆÅÀ¤Î¿§¾ðÊó¤òÇÛÎó¤Ë³ÊǼ¤¹¤ë
PRINT "²èÁü¤ÎÂ礤µ ½Ä:";h;" ²£:";w
!SET BITMAP SIZE w,h !¥¦¥£¥ó¥É¥¦¤ÎÂ礤µ¤ò²èÁü¤Ë¹ç¤ï¤»¤ë
LET A=5 !³ÈÂç½Ì¾®Î¨ A/N
!LET A=11 !³ÈÂç½Ì¾®Î¨
LET ww=INT(w*A/N+0.5) !ÊÑ´¹¸å¤Î²èÁü¤ÎÂ礤µ
LET hh=INT(h*A/N+0.5)
PRINT A;"/";N;"ÇܡʽIJ£Èæ¤Ï¸ÇÄê¡Ë ½Ä:";hh;" ²£:";ww
IF ww<=0 OR hh<=0 THEN
PRINT "²èÁü¤ÎÂ礤µ¤¬£°¤Þ¤¿¤ÏÉé¤Ë¤Ê¤ê¤Þ¤¹¡£"
STOP
END IF
DIM q(ww,hh) !ÊÑ´¹¸å¤Î²èÁü¤ò³ÊǼ¤¹¤ëÇÛÎó
LET t0=TIME
DIM TBLa(0 TO A-1,0 TO A-1)
MAT TBLa=ZER
FOR k=0 TO A-1 !A¡ßA¥Ö¥í¥Ã¥¯¤Î¦Õk(i)¤Î¥Æ¡¼¥Ö¥ë¤ò¤Ä¤¯¤ë
FOR i=0 TO A-1
LET TBLa(k,i)=phi(k,i,A)
NEXT i
NEXT k
DIM iTBLa(0 TO A-1,0 TO A-1)
MAT iTBLa=TRN(TBLa)
FOR by=0 TO INT((h-1)/N) !¥Ö¥í¥Ã¥¯Ã±°Ì¤Ëʬ³ä¤¹¤ë
FOR bx=0 TO INT((w-1)/N)
FOR j=1 TO N !¥Ö¥í¥Ã¥¯Æâ¤Î²èÁü
LET y=by*N+j
IF y>h THEN EXIT FOR !²¼Ã¼¤Ê¤é
FOR i=1 TO N
LET x=bx*N+i
IF x>w THEN EXIT FOR !±¦Ã¼¤Ê¤é
!!!PRINT x;y,i;j
LET c=p(x,y)
ASK COLOR MIX(c) r,g,b !RGB¤ò¼èÆÀ¤¹¤ë
DIM Br(N,N),Bg(N,N),Bb(N,N) !²èÁǤο§Ç»ÅÙ¡¡¢¨²èÁü¿®¹æ f(i,j)
LET Br(i,j)=r
LET Bg(i,j)=g
LET Bb(i,j)=b
NEXT i
NEXT j
!¢¨½Ì¾®¤Ê¤é¹â¼þÇÈÀ®Ê¬¤Î¹Ô¤ÈÎó¤ò½ü¤¯¡¢³ÈÂç¤Ê¤éÉÔÂÉôʬ¤Ï£°¤òÊ䤦
DIM Tr(A,A),Tg(A,A),Tb(A,A)
IF A>N THEN !³ÈÂç¤Ê¤é
MAT Tr=ZER(A,A)
MAT Tg=ZER(A,A)
MAT Tb=ZER(A,A)
END IF
FOR j=1 TO MIN(N,A) !copy it
FOR i=1 TO MIN(N,A)
LET Tr(i,j)=BVr(i,j)
LET Tg(i,j)=BVg(i,j)
LET Tb(i,j)=BVb(i,j)
NEXT i
NEXT j
DEF ha(f)=MOD(f,cEps*10) !ɾ²Á´Ø¿ô
SUB hatch(t, x,y,c) !¥Ï¥Ã¥Á·Á¾õ¤Ê¤éÅÀ(x,y)¤òÉÁ¤¯
LET flg=0
IF (t=1 OR t=5) AND ha(y)<cEps THEN LET flg=1 !²£
IF (t=2 OR t=5) AND ha(x)<cEps THEN LET flg=1 !½Ä
IF (t=3 OR t=6) AND ha(x+y)<cEps THEN LET flg=1 !º¸¼Ð¤á
IF (t=4 OR t=6) AND ha(x-y)<cEps THEN LET flg=1 !±¦¼Ð¤á
IF t=0 OR flg=1 THEN !t=0¤Ï¥Ù¥¿Åɤê
SET POINT COLOR c
PLOT POINTS: x,y
END IF
END SUB
!¾ò·ï¤òËþ¤¿¤¹Îΰè¤òÉÁ¤¯
SET POINT STYLE 1 !¥É¥Ã¥È·Á¼°
FOR j=1 TO h !²èÌÌÁ´ÂΤòÁöºº¤¹¤ë
LET y=WORLDY(j) !¥É¥Ã¥È¤òxyºÂɸ¤ËÊÑ´¹¤¹¤ë
FOR i=1 TO w
LET x=WORLDX(i)
WHEN EXCEPTION IN
!ÉÔÅù¼°¤¬¼¨¤¹Îΰ衡¢¨y>f(x)¤Ïf(x)>0¡¢y<f(x)¤Ïf(x)<0¤ò°ÕÌ£¤¹¤ë
IF y>f(x) THEN CALL hatch(4, x,y,4) !¾ò·ï¤òËþ¤¿¤¹¤Ê¤é
IF g(x,y)<0 THEN CALL hatch(3, x,y,2)
!¶ÊÀþ¤òÉÁ¤¯¡¡¢¨y=f(x)
FOR x=a TO b STEP cEps
WHEN EXCEPTION IN
PLOT LINES: x,f(x); !ÀÞ¤ìÀþ¤Ç¶á»÷¤¹¤ë
USE
PLOT LINES
END WHEN
NEXT x
PLOT LINES
PLOT TEXT ,AT -2,4: "f(x)"
!¶ÊÀþ¤òÉÁ¤¯¡¡¢¨Ï¢Â³¤Êf(x,y)=0
SET POINT COLOR 1
FOR y=c TO d STEP cEps
LET x=a
LET z=g(x,y)
FOR x=a TO b STEP cEps
LET z0=z
LET z=g(x,y)
IF z0*z<0 THEN PLOT POINTS: x,y !Éä¹æ¤¬ÊѤï¤ì¤Ð
NEXT x
NEXT y
PLOT TEXT ,AT -3,-3: "g(x)"
LET ba=b-a
LET hit=0
FOR i=1 TO N
LET x=RND*ba+a !N¸Ä¤Î°ìÍÍÍð¿ô
LET y=RND*c
IF y<f(x) THEN LET hit=hit+1 !f¤è¤ê²¼¤ÎÎΰè
NEXT i
LET S=c*ba * hit/N !ĹÊý·Á¤È¤ÎÌÌÀÑÈæ
IF X ¡ã¡á 10 THEN PRINT USING "¡ã###" : 123
IF X ¡ã¡ä 10 THEN PRINT USING "¡ã%%%" : 123
IF X¡ã¡á10 THEN PRINT USING "¡ã###":123
IF X¡ã¡ä10 THEN PRINT USING "¡ã%%%":123
PRINT USING "#¡ã" : w10, w1
PRINT USING "#¡ã":w10, w1
¡¡¤È½ñ¤¤¤¿¤È¤¹¤ë¡£
IF X <= 10 THEN PRINT USING "<###" : 123
IF X <> 10 THEN PRINT USING "<%%%" : 123
IF X<=10 THEN PRINT USING "<###":123
IF X<>10 THEN PRINT USING "<%%%":123
PRINT USING "#<" : w10, w1
PRINT USING "#<":w10, w1
IF MOD(p(1),3)=0 THEN !³Æ·å¤ÎϤ¬£³¤ÎÇÜ¿ô¤Ê¤é
PRINT p(10) !x=k1+k2*10+k3*100+ ¡Ä
ELSEIF k1=3 OR k2=3 THEN !¤¤¤º¤ì¤«¤¬£³¤È¤Ê¤ë
PRINT p(10) !x=k1+k2*10+k3*100+ ¡Ä
END IF
DIM CC(K) !Äê¿ô (1 1 1 ¡Ä)
MAT CC=CON
DIM BB(K) !Äê¿ô (1 10 100 ¡Ä)
FOR i=1 TO K
LET BB(i)=10^(i-1) !°Ì
NEXT i
DIM V(K) !¥Ù¥¯¥È¥ë
FOR k2=0 TO 9 !½½¤Î°Ì
LET V(2)=k2
FOR k1=0 TO 9 !°ì¤Î°Ì
LET V(1)=k1
IF MOD(DOT(V,CC),3)=0 THEN !³Æ·å¤ÎϤ¬£³¤ÎÇÜ¿ô¤Ê¤é
PRINT DOT(V,BB) !x=k1+k2*10+k3*100+ ¡Ä
ELSEIF V(1)=3 OR V(2)=3 THEN !¤¤¤º¤ì¤«¤¬£³¤È¤Ê¤ë
PRINT DOT(V,BB) !x=k1+k2*10+k3*100+ ¡Ä
END IF
FUNCTION tr(A(,)) !¹ÔÎóA¤Î¥È¥ì¡¼¥¹
LET t=0 !ÂгÑÀ®Ê¬¤ÎÏÂ
FOR m=1 TO MIN(UBOUND(A,1),UBOUND(A,2))
LET t=t+A(m,m)
NEXT m
LET tr=t
END FUNCTION
LET K=4 !·å¿ô
DIM B(K,1) !Äê¿ô t[1 10 100 ¡Ä]
FOR i=1 TO K
LET B(i,1)=10^(i-1) !°Ì
NEXT i
DIM C(1,K) !Äê¿ô [1 1 1 ¡Ä]
MAT C=CON
DIM TT(K,1),X(1,1) !ºî¶ÈÍÑ
DIM A(K,K) !ÂгѹÔÎó
MAT A=ZER
FOR k2=0 TO 9 !½½¤Î°Ì
LET A(2,2)=k2
FOR k1=0 TO 9 !°ì¤Î°Ì
LET A(1,1)=k1
IF MOD(tr(A),3)=0 THEN !³Æ·å¤ÎϤ¬£³¤ÎÇÜ¿ô¤Ê¤é
MAT TT=A*B !x=k1+k2*10+k3*100+ ¡Ä
MAT X=C*TT
MAT PRINT X; !PRINT X(1,1)
ELSEIF A(1,1)=3 OR A(2,2)=3 THEN !¤¤¤º¤ì¤«¤¬£³¤È¤Ê¤ë
MAT TT=A*B !x=k1+k2*10+k3*100+ ¡Ä
MAT X=C*TT
MAT PRINT X;
END IF
PUBLIC NUMERIC ANSWER_COUNT !²òÅú¿ô
LET ANSWER_COUNT=0
PUBLIC STRING num$
LET num$="0123456789ABCDEF" !N¿ÊË¡¤Î¿ô»ú
DIM M(0 TO N-1,0 TO N-1) !Ê¿Êý¤ÎÊý¿Ø
MAT M=(-1)*CON
SET WINDOW -1,N+1,N+1,-1
DRAW grid
LET t0=TIME
CALL BackTrack(N,M,0) !º¸¾å¤«¤é
PRINT "·×»»»þ´Ö=";TIME-t0
END
EXTERNAL SUB BackTrack(N,M(,),p) !¡Êº¸¾å¤«¤é¤ÎÏ¢ÈÖ¡Ë°ÌÃÖp¤òÄ´ºº¤¹¤ë
IF p<N*N THEN !¤¹¤Ù¤Æ¤¬Ëä¤Þ¤ë¤Þ¤Ç
LET row=INT(p/N) !¹Ô¤ÈÎó¤Ë´¹»»¤¹¤ë
LET col=MOD(p,N)
FOR k=0 TO N*N-1 !£°¡ÁN*N-1ÈϰϤοô»ú¤ò
CALL CheckRule(N,M, row,col,k, rc)!Ì·½â¤Ê¤¯ÃÖ¤±¤ì¤Ð
IF rc=1 THEN
SET TEXT COLOR 1
PLOT TEXT ,AT col+0.5,row+0.5: STR$(k)
LET M(row,col)=k !¤³¤³¤ËÃÖ¤¤¤Æ¤ß¤ë
CALL BackTrack(N,M,p+1) !¼¡¤Ø
LET M(row,col)=-1 !¼è¤ê¾Ã¤¹
SET TEXT COLOR 0
PLOT TEXT ,AT col+0.5,row+0.5: STR$(k)
END IF
NEXT k
ELSE !¤¹¤Ù¤ÆËä¤Þ¤Ã¤¿¤é
LET ANSWER_COUNT=ANSWER_COUNT+1 !²òÅú¿ô
PRINT ANSWER_COUNT
FOR i=0 TO N-1
FOR j=0 TO N-1
LET t=M(i,j)
LET k1=MOD(t,N)+2 !N¿ÊË¡¤Ç¤Î³Æ·å¤ÎÃÍ¡Êʸ»ú°ÌÃÖ¤ò²ÃÌ£¡Ë
LET k2=INT(t/N)+2
PRINT num$(k2:k2); num$(k1:k1); " "; !²ò¤òɽ¼¨¤¹¤ë
NEXT j
PRINT
NEXT i
PRINT
END IF
END SUB
EXTERNAL SUB CheckRule(N,M(,), row,col,K, rc) !Ʊ¤¸¿ô¤¬¤¢¤ë¤«¤É¤¦¤«³Îǧ¤¹¤ë
LET rc=0
FOR y=0 TO N-1 !Ëä¤Þ¤Ã¤Æ¤¤¤ëÈϰϤÇ̤»ÈÍѤοô»ú¤«
FOR x=0 TO N-1
IF y>=row AND x>=col THEN EXIT FOR
IF M(y,x)=K THEN EXIT SUB !¸«¤Ä¤«¤Ã¤¿¤Î¤Ç¡¢£Î£Ç¡ª
NEXT x
NEXT y
LET k1=MOD(K,N) !N¿ÊË¡¤Ç¤Î£±·åÌÜ
LET k2=INT(K/N) !N¿ÊË¡¤Ç¤Î£²·åÌÜ
FOR y=0 TO row-1 !Îó
LET t=M(y,col)
IF MOD(t,N)=k1 THEN EXIT SUB
IF INT(t/N)=k2 THEN EXIT SUB
NEXT y
FOR x=0 TO col-1 !¹Ô
LET t=M(row,x)
IF MOD(t,N)=k1 THEN EXIT SUB
IF INT(t/N)=k2 THEN EXIT SUB
NEXT x
PUBLIC STRING num$
LET num$="0123456789ABCDEF" !N¿ÊË¡¤Î¿ô»ú
DIM M(0 TO N*N-1) !Ê¿Êý¤ÎÊý¿Ø
MAT M=(-1)*CON
FOR i=0 TO N-1 !ɸ½à·Á¤Î¾ì¹ç¡¡¢¨£±¹ÔÌܤȣ±ÎóÌܤ¬À°Î󤷤Ƥ¤¤ë
LET M(i*N+0)=i
LET M(0*N+i)=i
NEXT i
LET t0=TIME
CALL BackTrack(N,M,0) !º¸¾å¤«¤é
PRINT "·×»»»þ´Ö=";TIME-t0
END
EXTERNAL SUB BackTrack(N,M(),p) !¡Êº¸¾å¤«¤é¤ÎÏ¢ÈÖ¡Ë°ÌÃÖp¤òÄ´ºº¤¹¤ë
IF p<N*N THEN !¤¹¤Ù¤Æ¤¬Ëä¤Þ¤ë¤Þ¤Ç
IF M(p)>=0 THEN !´û¤ËÃÖ¤¤¤Æ¤¢¤ì¤Ð
CALL BackTrack(N,M,p+1) !¼¡¤Ø
ELSE
FOR k=0 TO N-1 !¿ô»ú£°¡ÁN-1¤ò
CALL CheckRule(N,M, p,k, rc)!Ì·½â¤Ê¤¯ÃÖ¤±¤ì¤Ð
IF rc=1 THEN
LET M(p)=k !¤³¤³¤ËÃÖ¤¤¤Æ¤ß¤ë
CALL BackTrack(N,M,p+1) !¼¡¤Ø
LET M(p)=-1 !¼è¤ê¾Ã¤¹
END IF
NEXT k
END IF
ELSE !¤¹¤Ù¤ÆËä¤Þ¤Ã¤¿¤é
LET CntOfLM=CntOfLM+1 !²òÅú¿ô
PRINT CntOfLM
FOR i=0 TO N-1
FOR j=0 TO N-1
LET t=M(i*N+j)+1
PRINT num$(t+1:t+1); " "; !²ò¤òɽ¼¨¤¹¤ë
NEXT j
PRINT
NEXT i
PRINT
END IF
END SUB
EXTERNAL SUB CheckRule(N,M(), p,K, rc) !Ʊ¤¸¿ô¤¬¤¢¤ë¤«¤É¤¦¤«³Îǧ¤¹¤ë
LET rc=0
LET row=INT(p/N) !¹Ô¤ÈÎó¤Ë´¹»»¤¹¤ë
LET col=MOD(p,N)
FOR i=0 TO row-1 !Îó
IF M(i*N+col)=K THEN EXIT SUB
NEXT i
FOR i=0 TO col-1 !¹Ô
IF M(row*N+i)=K THEN EXIT SUB
NEXT i
!¢¨N=1,2,3,4,5,6,7,¡Ä¤Ê¤é¡¢1,1,1,4,56,9408,16942080,¡Ä¤È¤Ê¤ë¡£
PUBLIC NUMERIC LM(9408,0 TO 35) !ɸ½à·Á¥é¥Æ¥óÊý¿Ø N=6
PUBLIC NUMERIC CntOfLM !¤½¤Î¿ô
LET CntOfLM=0
DIM M(0 TO N*N-1) !Ê¿Êý¤ÎÊý¿Ø
MAT M=(-1)*CON
FOR i=0 TO N-1 !ɸ½à·Á¡¡¢¨£±¹ÔÌܤȣ±ÎóÌܤ¬À°Î󤷤Ƥ¤¤ë
LET M(i*N+0)=i
LET M(0*N+i)=i
NEXT i
LET t0=TIME
CALL BackTrack(N,M,0) !º¸¾å¤«¤é
PRINT CntOfLM
PRINT "·×»»»þ´Ö=";TIME-t0
LET t0=TIME
PUBLIC NUMERIC ANSWER_COUNT !²òÅú¿ô
LET ANSWER_COUNT=0
LET cnt=0 !¸¡¾Ú²ó¿ô
LET cc=comb(CntOfLM+2-1,2)
DIM A(0 TO N-1,0 TO N-1),B(0 TO N-1,0 TO N-1)
FOR i=1 TO CntOfLM !ɸ½à·ÁA¤Èɸ½à·ÁB¤ÎŸ³«¤È¤Î½ÅÊ£Áȹ礻 56H2
FOR y=0 TO N-1 !A¤ò»ØÄꤹ¤ë
FOR x=0 TO N-1
LET A(y,x)=LM(i,y*N+x)
NEXT x
NEXT y
FOR j=i TO CntOfLM
LET cnt=cnt+1 !¿ÊĽ
PRINT cnt;"/";cc
FOR y=0 TO N-1 !B¤ò»ØÄꤹ¤ë
FOR x=0 TO N-1
LET B(y,x)=LM(j,y*N+x)
NEXT x
NEXT y
DIM R(N) !½çÎó¤Î½é´üÃÍ
FOR k=1 TO N
LET R(k)=k
NEXT k
CALL RPerm(N,A,B, R,2) !¤Þ¤º¹Ô½ç¤ò»ØÄꤹ¤ë¡¡¢¨£±¹ÔÌܤϸÇÄê
NEXT j
NEXT i
IF ANSWER_COUNT=0 THEN PRINT "²ò¤Ê¤·"
PRINT "·×»»»þ´Ö=";TIME-t0
END
EXTERNAL SUB BackTrack(N,M(),p) !¡Êº¸¾å¤«¤é¤ÎÏ¢ÈÖ¡Ë°ÌÃÖp¤òÄ´ºº¤¹¤ë
IF p<N*N THEN !¤¹¤Ù¤Æ¤¬Ëä¤Þ¤ë¤Þ¤Ç
IF M(p)>=0 THEN !´û¤ËÃÖ¤¤¤Æ¤¢¤ì¤Ð
CALL BackTrack(N,M,p+1) !¼¡¤Ø
ELSE
FOR k=0 TO N-1 !¿ô»ú£°¡ÁN-1¤ò
CALL CheckRule(N,M, p,k, rc)!Ì·½â¤Ê¤¯ÃÖ¤±¤ì¤Ð
IF rc=1 THEN
LET M(p)=k !¤³¤³¤ËÃÖ¤¤¤Æ¤ß¤ë
CALL BackTrack(N,M,p+1) !¼¡¤Ø
LET M(p)=-1 !¼è¤ê¾Ã¤¹
END IF
NEXT k
END IF
ELSE !¤¹¤Ù¤ÆËä¤Þ¤Ã¤¿¤é
LET CntOfLM=CntOfLM+1 !¿ô¤ÈÇÛÃÖ¤òµÏ¿¤¹¤ë
FOR i=0 TO N*N-1
LET LM(CntOfLM,i)=M(i)
NEXT i
END IF
END SUB
EXTERNAL SUB CheckRule(N,M(), p,K, rc) !Ʊ¤¸¿ô¤¬¤¢¤ë¤«¤É¤¦¤«³Îǧ¤¹¤ë
LET rc=0
LET row=INT(p/N) !¹Ô¤ÈÎó¤Ë´¹»»¤¹¤ë
LET col=MOD(p,N)
FOR i=0 TO row-1 !Îó
IF M(i*N+col)=K THEN EXIT SUB
NEXT i
FOR i=0 TO col-1 !¹Ô
IF M(row*N+i)=K THEN EXIT SUB
NEXT i
LET rc=1 !¸«¤Ä¤«¤é¤Ê¤¤¤Î¤Ç¡¢£Ï£Ë¡ª
END SUB
EXTERNAL SUB RPerm(N,A(,),B(,), P(),i) !½çÎó¤òÀ¸À®¤·¤Æ¹Ô¤ÎʤÓÂؤ¨¡¡¢¨¼½ñ¼°½ç¤Ç¤Ï¤Ê¤¤
IF I<N THEN
FOR j=i TO N
LET t=P(i) !iÈÖÌܤÈjÈÖÌܤò¸ò´¹¤¹¤ë
LET P(i)=P(j)
LET P(j)=t
CALL RPerm(N,A,B, P,i+1) !ºÆµ¢¸Æ½Ð¤·
LET t=P(i) !¸µ¤ËÌ᤹
LET P(i)=P(j)
LET P(j)=t
NEXT j
ELSE !´°Î»¤Ê¤é
DIM C(N) !½çÎó¤Î½é´üÃÍ
FOR j=1 TO N
LET C(j)=j
NEXT j
CALL CPerm(N,A,B,P,C,1) !º£ÅÙ¤ÏÎó½ç¤ò»ØÄꤹ¤ë
END IF
END SUB
EXTERNAL SUB CPerm(N,A(,),B(,),R(), P(),i) !½çÎó¤òÀ¸À®¤·¤ÆÎó¤ÎʤÓÂؤ¨¡¡¢¨¼½ñ¼°½ç¤Ç¤Ï¤Ê¤¤
IF I<N THEN
FOR j=i TO N
LET t=P(i) !iÈÖÌܤÈjÈÖÌܤò¸ò´¹¤¹¤ë
LET P(i)=P(j)
LET P(j)=t
CALL CPerm(N,A,B,R, P,i+1) !ºÆµ¢¸Æ½Ð¤·
LET t=P(i) !¸µ¤ËÌ᤹
LET P(i)=P(j)
LET P(j)=t
NEXT j
ELSE !¥ª¥¤¥é¡¼Êý¿Ø¤ò¤Ä¤¯¤Ã¤Æ¸¡¾Ú¤¹¤ë
DIM EM(N,N) !»ÈÍѤǤ¤ë¿ô»ú¤ÎÁȤȻÈÍѾõ¶·
MAT EM=ZER
!¢¨¥é¥Æ¥óÊý¿Ø¤ÎÁȹ礻¤Ê¤Î¤Ç¡¢¹Ô¤ÈÎó¤Î½ÅÊ£¤Ï¤Ê¤¤¡£
FOR i=0 TO N-1 !Êý¿ØÁ´ÂΤÇƱ¤¸¿ô¤¬¤¢¤ë¤«¤É¤¦¤«³Îǧ¤¹¤ë
FOR j=0 TO N-1
LET rr=A(i,j)+1 !¥ª¥¤¥é¡¼Êý¿Ø¤ò¤Ä¤¯¤ë
LET cc=B(R(i+1)-1,P(j+1)-1)+1
IF EM(rr,cc)=1 THEN EXIT SUB !¤½¤Î¿ô»ú¤Ï»ÈÍÑÃæ¤Ê¤Î¤Ç£Î£Ç¡ª
LET EM(rr,cc)=1
NEXT j
NEXT i
LET ANSWER_COUNT=ANSWER_COUNT+1 !²òÅú¿ô
PRINT ANSWER_COUNT
FOR i=0 TO N-1 !Åú¤¨¤òɽ¼¨¤¹¤ë
FOR j=0 TO N-1
PRINT (A(i,j)+1)*10 + B(R(i+1)-1,P(j+1)-1)+1 ;
NEXT j
PRINT
NEXT i
OPTION BASE 0
LET N= 3 !¡¡2,3,4,5,6
DIM lb(9408,N,N) !¡¡N=1¡Á7: 1,1,1,4,56,9408,16942080 N=7¤ÏÈ󸽼ÂŪ
DIM wb(N,N), xidx(N), yidx(N), fb(N,N)
!
CALL main
SUB makelb(x, y)
local i,j
FOR i=0 TO N-1
FOR j=0 TO x-1
IF i=wb(y,j) THEN EXIT FOR ! break;
NEXT j
IF j>x-1 THEN
FOR j=0 TO y-1
IF i=wb(j,x) THEN EXIT FOR ! break;
NEXT j
IF j>y-1 THEN
LET wb(y,x)= i
IF y=N-1 AND x=N-1 THEN
!----memcpy(lb[lbs++], wb, sizeof(wb));
FOR a=0 TO N
FOR b=0 TO N
LET lb(lbs,a,b)=wb(a,b)
NEXT b
NEXT a
LET lbs=lbs+1
!---------------
EXIT SUB ! return;
END IF
IF
y=N-1 THEN CALL makelb(x+1, 1) ELSE CALL makelb((x),y+1)
END IF
END IF
NEXT i
END SUB
SUB echk
local i,j
MAT fb=ZER ! memset(fb, 0, sizeof(fb));
FOR i= 0 TO N-1
FOR j= 0 TO N-1
IF fb( lb(p,i,j), lb(q,yidx(i),xidx(j)) )>0 THEN EXIT SUB ! return;
LET fb( lb(p,i,j), lb(q,yidx(i),xidx(j)) )=1
NEXT j
NEXT i
FOR i= 0 TO N-1
FOR j= 0 TO N-1
PRINT USING "%#": lb(p,i,j)+1, lb(q,yidx(i),xidx(j))+1;
IF j=N-1 THEN PRINT ELSE PRINT " ";
NEXT j
NEXT i
STOP ! exit(0);
END SUB
SUB check1(n_)
local i
FOR i=n_ TO N-1
swap xidx(i),xidx(n_)
!-----check2(n_)
local i_
FOR i_= n_ TO N-1
swap yidx(i_),yidx(n_)
IF ( yidx(n_)<>xidx(n_)) AND (n_<>1 OR yidx(n_)< xidx(n_) ) THEN
IF n_=N-1 THEN CALL echk ELSE CALL check1(n_+1)
END IF
swap yidx(i_),yidx(n_)
NEXT i_
!------
swap xidx(i),xidx(n_)
NEXT i
END SUB
SUB main
FOR i= 0 TO N-1
LET wb(i,0)= i
LET wb(0,i)= i
NEXT i
LET lbs = 0
PRINT "N=";N; ! Äɲä·¤¿É½¼¨
CALL makelb(1,1)
PRINT "lbs=";lbs !ÄɲÃ
MAT PRINT wb !¡¡¡¡ÄɲÃ
LET count= 0
FOR p=0 TO lbs-1
FOR q=p TO lbs-1
LET count=count+1
IF MOD(count,1000)=0 THEN PRINT count
FOR i= 0 TO N-1
LET yidx(i)= i
LET xidx(i)= i
NEXT i
CALL check1(1)
NEXT q
NEXT p
PRINT "²ò¤Ï¸«¤Ä¤«¤ê¤Þ¤»¤ó¤Ç¤·¤¿."
END SUB
SUB dec(C(),p, w) !¥Ñ¥±¥Ã¥ÈÆâ¾å¤«¤ép°ÌÃ֤Υ«¡¼¥É¤òºï½ü¤¹¤ë
LET w=C(p)
FOR i=p TO C(0)-1 !Á°¤ËµÍ¤á¤ë
LET C(i)=C(i+1)
NEXT i
LET C(0)=C(0)-1
END SUB
SUB inc(C(),p,w) !¥Ñ¥±¥Ã¥ÈÆâ¾å¤«¤ép°ÌÃ֤˥«¡¼¥É¤òÄɲ乤ë
IF p<=C(0) THEN
FOR i=C(0) TO p STEP -1 !¸å¤í¤Ë¤º¤é¤¹
LET C(i+1)=C(i)
NEXT i
ELSE
LET p=C(0)+1 !ºÇ¸å
END IF
LET C(p)=w
LET C(0)=C(0)+1
END SUB
DIM TT(0 TO 13*4+1)
SUB add(C1(),C2(), C()) !C1¤ò¾å¡¢C2¤ò²¼¤Ë¥Ñ¥±¥Ã¥È¤ò½Å¤Í¤ë
FOR i=1 TO C1(0)
LET TT(i)=C1(i)
NEXT i
FOR i=1 TO C2(0) !³¤±¤Æ
LET TT(C1(0)+i)=C2(i)
NEXT i
LET C(0)=C1(0)+C2(0)
FOR i=1 TO C(0)
LET C(i)=TT(i)
NEXT i
END SUB
SUB clr(C()) !¥Ñ¥±¥Ã¥È¤ò¥¯¥ê¥¢¤¹¤ë
LET C(0)=0
END SUB
SUB rev(C()) !¥Ñ¥±¥Ã¥È¤ò΢ÊÖ¤¹
FOR i=1 TO INT(C(0)/2)
swap C(i),C(C(0)-i+1)
NEXT i
END SUB
SUB disp(C(),m$) !¥Ñ¥±¥Ã¥È¤ò¾å¤«¤é½ç¤Ëɽ¼¨¤¹¤ë
PRINT m$;"(";C(0);"Ëç)";
FOR i=1 TO C(0)
PRINT C(i);
NEXT i
PRINT
END SUB
!-------------------- ¤³¤³¤Þ¤Ç¤¬¥µ¥Ö¥ë¡¼¥Á¥ó
LET N=12 !Ëç¿ô
DIM S(0 TO N),H(0 TO N) !¥¹¥Ú¡¼¥É¡¢¥Ï¡¼¥È¥Ñ¥±¥Ã¥È¤Î½é´ü²½
FOR i=1 TO N !À°Îó
LET S(i)=i !¥¹¥Ú¡¼¥É 1¡Á13
LET H(i)=i+13*2 !¥Ï¡¼¥È 27¡Á39
NEXT i
LET H(0)=N !Ëç¿ô
LET S(0)=N
!¥Æ¡¼¥Ö¥ë¤Î½é´ü²½
DIM Y1(0 TO N),Y2(0 TO N),Y3(0 TO N) !»³£±¡¢»³£²¡¢¼Î¤Æ¾ì
CALL clr(Y1) !»³¤Î¥¯¥ê¥¢
CALL clr(Y2)
CALL clr(Y3)
CALL dump !ÆâÍƤò³Îǧ¤¹¤ë
SUB dump
CALL disp(S,"¥¹¥Ú¡¼¥É") !¥È¥ì¡¼¥¹
CALL disp(H,"¥Ï¡¼¥È")
CALL disp(Y1,"»³£±")
CALL disp(Y2,"»³£²")
CALL disp(Y3,"¼Î¤Æ¾ì")
PRINT
END SUB
SUB routine !ºî¶È¤ÎÄêµÁ
FOR x=1 TO N !¼ê»ý¤Á¤Î¥«¡¼¥É¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
PRINT x;"ËçÌܤò¥Æ¡¼¥Ö¥ë¤Ø"
CALL dec(S,1,w) !ºï½ü¤¹¤ë
IF x=K THEN !°ìÃפ¹¤ëËç¿ôÌܤʤé¼Î¤Æ¾ì¤Ø
!IF MOD(x,K)=0 THEN !°ìÃפ¹¤ëËç¿ôÌܤʤé¼Î¤Æ¾ì¤Ø
CALL inc(Y3,1,w)
CALL dec(H,1,w) !ÂåÂؤȤ·¤Æ¾ì¤«¤é
END IF
IF MOD(x,2)=0 THEN !º¸±¦¸ò¸ß¤Ç»³¤ËÃÖ¤¯
CALL inc(Y2,1,w)
ELSE
CALL inc(Y1,1,w)
END IF
IF UCASE$(c$)="H" THEN
LET w=H(K) !¥¹¥Ú¡¼¥É¤ÎÎó¤Ë¤Ê¤Ã¤Æ¤¤¤ë
LET w=S(w)
ELSE
LET w=MOD(S(K),13) !¥Ï¡¼¥È¤ÎÎó¤Ë¤Ê¤Ã¤Æ¤¤¤ë
LET w=H(w)
END IF
PRINT mid$(mk$,INT(w/13)+1,1); MOD(w,13)
PRINT "----- ºÇ½é¤Î¾õÂÖ -----"
CALL ready
CALL printa(s) !¡¡¥¹¥Ú¡¼¥É
CALL printa(h) !¡¡¥Ï¡¼¥È
PRINT
!
FOR R=1 TO 12
PRINT "----- Request";R;"¤Î¾ì¹ç-----"
CALL ready
LET k=1
DO WHILE k< 13
FOR i=1 TO 12
LET j=MOD(i,2)*7+INT(i/2) !¡¡Ê¬¤±¤¿£²¤Ä¤ò½Å¤Í¤¿»þ¤Î°ÌÃÖ¡£
IF i=R THEN
LET t(j)=h(k) !¡¡¥Ï¡¼¥È¤ò¥Æ¡¼¥Ö¥ë¤Ø
LET w(k)=s(i) !¡¡¼ê¸µ(ºÇ½é¥¹¥Ú¡¼¥É)¤ò¡Ö¼Î¤Æ¡×¤Ø
LET k=k+1
ELSE
LET t(j)=s(i) !¡¡¼ê¸µ(ºÇ½é¥¹¥Ú¡¼¥É)¤ò¥Æ¡¼¥Ö¥ë¤Ø
END IF
NEXT i
MAT s=t !¡¡¥Æ¡¼¥Ö¥ë¤ò¼ê¸µ(ºÇ½é¥¹¥Ú¡¼¥É)¤Ø
LOOP
CALL printa(s) !¡¡Èæ³Ó¡¦¡¦¡¦¼ê¸µ(ºÇ½é¥¹¥Ú¡¼¥É)
CALL printa(w) !¡¡Èæ³Ó¡¦¡¦¡¦¡Ö¼Î¤Æ¡×¤Î½Å¤Ê¤ê
PRINT
NEXT R
SUB printa(a())
FOR n=1 TO 12
PRINT USING "## ":a(n);
NEXT n
PRINT "¡¡¡Ä¸ß¤¤¤Ë Index."
END SUB
SUB ready
FOR i=1 TO 12
LET s(i)=i
LET h(i)=i
NEXT i
END SUB
!Êä½õ¥ë¡¼¥Á¥ó
SUB PermPrintOut(A()) !ɽ¼¨¤¹¤ë¡¡¢¨É¸½à·Á¡Ê£²¹Ô£îÎó¤Î¹ÔÎóɽµ¤¹¤ë¡Ë
!PRINT "¨£";
!FOR i=1 TO UBOUND(A)
! PRINT USING "###": i;
!NEXT i
!PRINT " ¨¤"
!PRINT "¨¦";
FOR i=1 TO UBOUND(A)
PRINT USING "###": A(i);
NEXT i
!PRINT " ¨¥";
PRINT
END SUB
!ÃÖ´¹
SUB PermIdentity(A()) !¹±ÅùÃÖ´¹
FOR i=1 TO UBOUND(A)
LET A(i)=i
NEXT i
END SUB
SUB PermMultiply(A(),B(), AB()) !ÀÑAB¡¡¢¨AB¡âBA¡¢A(BC)=(AB)C
LET ua=UBOUND(A)
LET ub=UBOUND(B)
IF ua=ub THEN
FOR i=1 TO ua
LET AB(i)=A(B(i)) !¢¨¹çÀ®¼ÌÁü(AB)(i)=A(B(i))
NEXT i
ELSE
PRINT "¼¡¸µ¤¬°ã¤¤¤Þ¤¹¡£A=";ua;" B=";ub
STOP
END IF
END SUB
!-------------------- ¤³¤³¤Þ¤Ç¤¬¥µ¥Ö¥ë¡¼¥Á¥ó
!main
LET N=12 !¢¨2,4,10,12
!A=¨£ 1 2 3 4 ¨¤=(1 2 4 3)¡¡¢¨£±¹ÔÌܤνçÈ֤ϸÇÄê¤È¤¹¤ë
!¡¡¨¦ 2 4 1 3 ¨¥
DATA 2,4,6,8,10,12,1,3,5,7,9,11 !ÇÛÎóÊÑ¿ô¤Î¡Öź¤¨»ú¤ÈÃ͡פËÂбþ¤µ¤»¤ë
!DATA 2,4,6,8,10,1,3,5,7,9 !N=10
!DATA 2,4,1,3 !N=4
!DATA 2,1 !N=2
DIM A(N)
MAT READ A
FOR i=1 TO N
PRINT USING "###": i;
NEXT i
PRINT
DIM B(N)
CALL PermIdentity(B) !½é´üÃÍ
DIM c(N)
FOR k=1 TO N !²ó¿ô
CALL PermMultiply(B,A,c) !¥·¥ã¥Ã¥Õ¥ë
PRINT "K=";k
CALL PermPrintOut(c) !²¿²ó¤«¼Â¹Ô¤¹¤ë¤È¸µ¤ËÌá¤ë
MAT B=c
NEXT k
!£±£³°Ê³°¤Î¿ô£Î¤Ë¡¢¼«Ê¬¼«¿È£Î¤ò²Ã¤¨¤Æ¿·¤·¤¤¿ô¤òºî¤ë¡£
!¤½¤Î¿ô¤¬£±£³¤è¤êÂ礤¤¤È¤¤Ï¡¢£±£³¤ò°ú¤¯¡£
DIM A(13),B(13)
FOR k=1 TO 12
LET A(k)=k
LET B(k)=0
NEXT k
FOR i=1 TO 12
FOR k=1 TO 12
LET B(k)=MOD(B(k)+A(k),13)
NEXT k
LET B(13)=13
MAT PRINT B;
NEXT i
END
2870 INPUT PROMPT "¹¥¤¤Ê»³¤òÁª¤Ö¡Ê1¡ÁK:K<=N,¤¿¤À¤·0¤Ï½ªÎ»¡Ë": x
2880
2890 DIM wlk(N)
2900 DATA 1,1,1,1,-2,1,-1,-3,4,3,2,1 !²ó¼ýÊýË¡¡¡¢¨£±¤Ê¤é±¦¤Ø£±¡¢¡Ý£²¤Ê¤éº¸¤Ø£²¤Î°Õ
2910 MAT READ wlk
2920 LET KEY1=wlk(K) !½ªÃ¼°ÌÃÖ¤òµ²±¤¹¤ë
2930
2940 DIM yy(0 TO N+1)
2950 CALL routine2_2 !³Æ»³¤«¤é²ó¼ý¤¹¤ë
!OPTION ARITHMETIC decimal_high
LET t0=TIME
DIM S(1000000) !S1,S2,¡Ä,Sn
LET S(1)=1
FOR k=2 TO 1000000
LET S(k)=S(k-1)+k !º¸ÊÕ 1+ ¡Ä +(k-1)+k ¤ÎÃÍ
NEXT k
LET c=0 !¸Ä¿ô
FOR n=1 TO 1000000
LET key=S(n)/2 !¡ÖÁ´ÂΤÎȾʬ¤ÎÃ͡פò¸«¤Ä¤±¤ë
LET L=1 !²¼¸Â
LET H=n !¾å¸Â
DO WHILE L<=H !µÕž¤·¤¿¤é½ªÎ»
LET M=INT((L+H)/2) !Ãæ±û
IF S(M)<=key THEN LET L=M+1 !¹Ê¤ê¹þ¤à
IF S(M)>=key THEN LET H=M-1
LOOP
!!!PRINT n;L;H
IF L=H+2 THEN !¸«¤Ä¤«¤Ã¤¿¤é
LET c=c+1
PRINT c;"¸ÄÌÜ"
PRINT "1 + ¡Ä +";M;"=";M+1; !º¸Êդȡá
IF M<n-1 THEN !À°·Á¤Î¤¿¤á
PRINT "+ ¡Ä +";n; !±¦ÊÕ
END IF
PRINT "¡Ê=";S(M);"¡Ë" !ÏÂ
END IF
NEXT n
PRINT "·×»»»þ´Ö=";TIME-t0
END
¡ü¡Ö£²¼¡ÊýÄø¼°¤ò²ò¤¯¡×¤ÎÊ̲ò¤È¤·¤Æ¤Î¥µ¥ó¥×¥ë
FOR k=1 TO 1000000
¡¡£î¤Ë¤Ä¤¤¤Æ¤Î£²¼¡ÊýÄø¼° n^2+n-2*(k^2+k)=0 ¤ò²ò¤¤¤ÆÀµ¤ÎÀ°¿ô²ò¤òÆÀ¤ë
NEXT k
¤³¤ì¤Ï¡¢¿ôÎó{Sk,Sk+1,¡Ä}¤ÎÃ椫¤é¡¢2*Sk¤òõ¤¹¤³¤È¤Ç¤¹¡£
̵¸Â¸Ä¤ÎÃæ¤òõº÷¤Ç¤¤Ê¤¤¤Î¤Ç¡¢¡Ê¼ÂºÝ¤Ï¾®¤µ¤¤½ç¤ËÀ°Î󤷤Ƥ¤¤ë¤Î¤ÇÅÓÃæ¤ÇÃæ»ß¤¹¤ë¡Ë
!OPTION ARITHMETIC decimal_high
LET t0=TIME
LET c=0 !¸Ä¿ô
FOR N=2 TO 1000000
LET S=N*(N+1)/2 !Á´Éô¤ÎÏÂ
LET a=INT(SQR(S)) !¡á¤¬Æþ¤ë²Õ½ê¤Î²ÄǽÀ
FOR k=a TO a+1
LET L=k*(k+1)/2 !º¸ÊÕ¤ÎÏÂ
IF 2*L=S THEN !2*º¸ÊÕ¡áÁ´Éô¤ÎϤʤ顢¾ò·ï¤ò¤ß¤¿¤¹
LET c=c+1
PRINT c;"¸ÄÌÜ"
PRINT "1 + ¡Ä +";k;"="; !º¸Êդȡá
IF i=N-1 THEN !À°·Á¤Î¤¿¤á
PRINT k+1;"¡Ê=";L;"¡Ë" !±¦ÊÕ¤ÈÏÂ
ELSE
PRINT k+1;"+ ¡Ä +";N;"¡Ê=";L;"¡Ë"
END IF
END IF
NEXT k
NEXT N
PRINT "·×»»»þ´Ö=";TIME-t0
END
!OPTION ARITHMETIC decimal_high
LET t0=TIME
LET a=1000000
LET n=1 !ÀèƬ¤«¤é
LET k=1
LET c=0 !¸Ä¿ô
DO UNTIL n>a OR k>a-1 !¤É¤Á¤é¤«¤Î¥Ç¡¼¥¿Î󤬽ª¤ï¤ë¤Þ¤Ç
LET s1=n*(n+1)/2 !¥Ç¡¼¥¿Îó¤òÆÀ¤ë
LET s2=2*k*(k+1)/2
IF s1=s2 THEN !¥Þ¡¼¥¸¤¹¤ë
LET c=c+1
PRINT c;"¸ÄÌÜ"
PRINT "1 + ¡Ä +";k;"=";k+1; !º¸Êդȡá
IF k<n-1 THEN !À°·Á¤Î¤¿¤á
PRINT "+ ¡Ä +";n; !±¦ÊÕ
END IF
PRINT "¡Ê=";s1/2;"¡Ë" !ÏÂ
LET k=k+1
LET n=n+1
ELSEIF s1>s2 THEN
LET k=k+1
ELSE
LET n=n+1
END IF
LOOP
PRINT "·×»»»þ´Ö=";TIME-t0
END
LET k=4 ! 4¹Ô
LET n=k*(k+1)/2 ! n=10
DIM a(k,k),check(n)
FOR maxn=1 TO CEIL(k/2)
FOR r=1 TO n^(n/2)
MAT check=ZER
LET a(1,maxn)=n
LET check(n)=1
FOR i=1 TO k
FOR j=1 TO k+1-i
IF NOT (i=1 AND j=maxn) THEN
DO
LET
num=INT((n-1)*RND)+1
LOOP UNTIL check(num)=0
LET a(i,j)=num
LET check(num)=1
END IF
NEXT j
NEXT i
!MAT PRINT a
CALL diff
IF p=0 THEN MAT PRINT a
LET p=0
NEXT r
NEXT maxn
SUB diff
FOR i=1 TO k-1
FOR j=1 TO k-i
IF ABS(a(i,j)-a(i,j+1))<>a(i+1,j) THEN
LET p=1
EXIT SUB
END IF
NEXT j
NEXT i
END SUB
END
DECLARE EXTERNAL SUB combi
PUBLIC NUMERIC k,n,h,pt,count
LET t0=TIME
LET k=5 ! ¹Ô¿ô
LET n=k*(k+1)/2 ! ºÇÂçÃÍ
LET h=INT(k/2) ! Ⱦʬ
LET pt=MOD(k,2) ! ´ñ¶ö
DIM nn(n-1),c(k-1)
MAT nn=ZER
LET count=0
LET j=0
CALL combi(nn,1,k-1,j,c)
PRINT TIME-t0;"ÉÃ",count;"²ó"
END
EXTERNAL SUB differ(p()) !Ãí°Õ:°ìÉô²þÎɤ·¤Þ¤·¤¿
DIM a(k,k),ck(n-1)
LET a(1,1)=n
FOR j=2 TO k
LET a(1,j)=p(j-1)
NEXT j
CALL check
FOR j=2 TO h
SWAP a(1,j-1),a(1,j)
CALL check
NEXT j
IF pt=1 AND p(1)<p(k-1) THEN ! n¤¬Ãæ±û¤Î¤È¤
SWAP a(1,h),a(1,h+1)
CALL check
END IF
SUB check
LET count=count+1
MAT ck=ZER
FOR r=1 TO k-1
LET ck(p(r))=1
NEXT r
FOR ii=1 TO k-1
FOR jj=1 TO k-ii
LET d=ABS(a(ii,jj)-a(ii,jj+1))
IF ck(d)=1 THEN EXIT SUB ! ¿ôÃͽÅÊ£
LET ck(d)=1
LET a(ii+1,jj)=d
NEXT jj
NEXT ii
MAT PRINT a; ! ²ò¤¢¤ê
END SUB
END SUB
REM ½½¿ÊBASICźÉÕ"\BASICw32\SAMPLE\COMBINAT.BAS"¤è¤ê
REM 1¡Án-1¤Î½¸¹ç¤«¤ér¸Ä¤òÁª¤ÖÁȹ礻¤òÀ¸À®¤¹¤ë¡£
EXTERNAL SUB combi(nn(),kk,r,j,c())
DECLARE EXTERNAL SUB permu
! kk°Ê¹ß¤Î¿ô¤«¤ér¸Ä¤òÁªÂò¤¹¤ë
IF r=0 THEN
FOR i=1 TO n-1
IF nn(i)=1 THEN
LET j=j+1
LET c(j)=i
END IF
NEXT i
!MAT PRINT c;
CALL permu(c,1)
LET j=0
ELSE
FOR i=kk TO n-r
LET nn(i)=1
CALL combi(nn,i+1,r-1,j,c)
LET nn(i)=0
NEXT i
END IF
END SUB
REM ½½¿ÊBASICźÉÕ"\BASICw32\SAMPLE\PERMUTAT.BAS"¤è¤ê
REM (k-1)¸Ä¤Î¿ôÃͤνçÎó¤ò¼½ñ¼°½ç½ø¤ÇÀ¸À®¤¹¤ë¡£
EXTERNAL SUB permu(p(),r)
DECLARE EXTERNAL SUB differ
IF r=k-1 THEN
!MAT PRINT p;
CALL differ(p)
ELSE
FOR i=r TO k-1
LET t=p(i)
FOR j=i-1 TO r STEP -1
LET p(j+1)=p(j)
NEXT j
LET p(r)=t
CALL permu(p,r+1)
LET t=p(r)
FOR j=r TO i-1
LET p(j)=p(j+1)
NEXT j
LET p(i)=t
NEXT i
END IF
END SUB
OPTION CHARACTER byte
SET TEXT BACKGROUND "opaque"
SET TEXT font"",14
OPTION BASE 0
DIM wb(8,8)
!
LET lb$=REPEAT$( CHR$(0),10000*8*8) ! N=1¡Á7: 1,1,1,4,56,9408,16942080
LET N= 6 ! 2,3,4,5,6
LET cp= 1000 ! ¥«¥¦¥ó¥¿¡¼¤Îɽ¼¨´Ö³Ö(1~20000)¡¢¾®¤µ¤¤¤È®ÅÙÄã²¼¡£Â礤¤¤ÈÃæ»ß¤¬º¤Æñ¡£
!
CALL main
SUB makelb(x,y)
local element
FOR element=0 TO N-1
FOR i=0 TO x-1
IF element=wb(y,i) THEN EXIT FOR ! break;
NEXT i
IF i>x-1 THEN
FOR i=0 TO y-1
IF element=wb(i,x) THEN EXIT FOR ! break;
NEXT i
IF i>y-1 THEN
LET wb(y,x)=element
IF y=N-1 AND x=N-1 THEN
!----memcpy(lb[lbs++], wb, sizeof(wb));
LET w=1+64*lbs
FOR i=0 TO N-1
FOR j=0 TO N-1
LET lb$(w+j:w+j)=CHR$(wb(i,j))
NEXT j
LET w=w+8
NEXT i
!--------¥â¥Ë¥¿¡¼
IF MOD(lbs,1000)=0 THEN PRINT "ºîÀ®Ãæ¡£N=";N;"lbs=";lbs
!--------
LET lbs=lbs+1
EXIT SUB ! return;
END IF
IF
y=N-1 THEN CALL makelb(x+1,1) ELSE CALL makelb((x),y+1)
END IF
END IF
NEXT element
END SUB
Á°²ó¡¡NO95 NO¤Î¸æ²óÅúÍÆñ¤¦¤´¤¶¤¤¤Þ¤·¤¿¡£»³Ã椵¤ó¤òÃ滳¤µ¤ó¤È´Ö°ã¤¨¤ÆÅê¹Æ¤·¤Þ¤·¤¿¡£¼ºÎé¤ò¸æµö¤·¤¯¤À¤µ¤¤¡£
¤½¤Î¸å¤À¤¤¤Ö10¿ÊBASIC¤ò¿Ê¤á¤Æ¤Þ¤¹¤¬¡¢²¼µ¤ÎÉÔ¶ñ¹ç¤Ç¥¹¥È¥Ã¥×¤·¤Æ¤Þ¤¹¡£
MAT T=INV(A)¡¡¤¬½ÐÍè¤Ê¤¤¤Î¤Ç¤¹¡£
OPTION ARITHMETIC COMPLEX
LET j=SQR(-1)
LET R1=5000
LET R2=5000
LET C1=0.1*10^( -6 )
LET C2=0.1*10^( -6 )
LET F=100
LET SZ=0.001
LET NP=4
LET ZC1=1/(2*PI*F*C1)
LET ZC2=1/(2*PI*F*C2)
OPTION BASE 1
PRINT "ZCI=";ZC1
DIM A(NP,NP),B(NP,NP),T(NP,NP),E1(NP)
LET A(1,2)=1/R1+SZ*j
LET A(2,3)=1/R2+SZ*j
LET A(2,4)=SZ+1/ZC1*j
LET A(3,4)=SZ+1/ZC2*j
MAT PRINT A
LET E1(1)=1
LET E1(4)=0
PRINT"²¼µ¤Î¤´¤È¤¯MAT PRINT E1¤È¤ä¤ë¤È²£¤Ë°ìʸ»ú¤Ë¤Ê¤ë¡£"
MAT PRINT E1
PRINT"²¼µ¤Î¤´¤È¤¯MAT PRINT USING REPEAT$RI¤Ç½Ä¤Ë°ìʸ»úʤÓÎÉ
¹¥¡£"
MAT PRINT USING REPEAT$(" #.#### ",1):E1
MAT T=INV(A)
> ¤Þ¤¿¡¢°ìÎó¤ÎE(5)¤Ê¤É¤òºî¤ê¡¢PRINT E ¡¡¤ò¤ä¤ë¤È¡¢²£°ìÎó¤Ëɽ¼¨¤·¤Þ¤¹¡£
> »Íü»ÒÌ֤Ρ¡A*E Åù¤ÏÂç¾æÉפǤ·¤ç¤¦¤«¡£½Ä¤ËÊѹ¹¤·¤ÆT=TRAN(E) ¤½¤·¤ÆA*T ¤Ç¤·¤ç¤¦¤«¡£
DIM A(3,3)
DIM X(3),B(3)
MAT B=A*X !(3¹Ô,3Îó)(3¹Ô,1Îó)=(3¹Ô,1Îó)¤È¤·¤Æ·×»»¤µ¤ì¤ë
MAT PRINT B !²£¤Ø
MAT B=X*A !(1¹Ô,3Îó)(3¹Ô,3Îó)=(1¹Ô,3Îó)¤È¤·¤Æ·×»»¤µ¤ì¤ë
MAT PRINT B !²£¤Ø
END
¤³¤Î¾ì¹ç¡¢X,B¤Ï¥Ù¥¯¥È¥ë°·¤¤¤Ë¤Ê¤ê¤Þ¤¹¡£
X,B¤ò¹ÔÎó¤È¤·¤Æ°·¤¦¾ì¹ç¤Ï¡¢¡ÊX,B¤ËÂФ·¤ÆTRN¤òŬÍѤ¹¤ë¾ì¹ç¡Ë
¹Ô¤Þ¤¿¤ÏÎó¤Î¤ß¤Î¹ÔÎó¤Ï¡¢¤¿¤È¤¨¤Ð
¡¡£³¹Ô£±Îó¤Ê¤é DIM B(3,1)
¡¡£±¹Ô£³Îó¤Ê¤é DIM B(1,3)
¤È¤·¤Æ¤¯¤À¤µ¤¤¡£
MAT READ px
DATA 0.20, 0.40, 0.60, 0.80, 0.70, 0.60, 0.50, 0.40, 0.30, 0.20, 0.40, 0.60
MAT READ py
DATA 0.11, 0.11, 0.11, 0.11, 0.29, 0.47, 0.65, 0.47, 0.29, 0.11, 0.11, 0.11
SET WINDOW -1/4,1/4, -1/4,1/4
!----------
LET N=3
DO
LET s=MOD(s,36)+1
LET s2=INT((s-1)/4)+1
SET DRAW mode hidden
CLEAR
DRAW D4(N) WITH SHIFT(-0.5,-0.5/SQR(3))*ROTATE(PI*2/36*s+PI)
SET DRAW mode explicit
WAIT DELAY 0.2
LOOP
!------
PICTURE D4(k)
IF 0< k THEN
DRAW D4(k-1) WITH SCALE(1/2,1/2)*SHIFT(1/4,SQR(3)/4) !¡¡¾å
DRAW D4(k-1) WITH SCALE(1/2,-1/2)*SHIFT(1/4,SQR(3)/4) !¡¡Ãæ
DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(-PI*2/3)*SHIFT(1/4,SQR(3)/4) !¡¡º¸
DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(PI*2/3)*SHIFT(1,0) !¡¡±¦
ELSE
DRAW Set01
END IF
END PICTURE
!------ ¼ï¤Î»°³Ñ¿Þ
PICTURE Set01
PLOT LINES: 0,0; 1,0 ;0.5,SQR(3)/2 ;0,0
SET AREA COLOR 5 !2
DRAW disk WITH SCALE(0.1)*SHIFT(px(s2),py(s2)) ! ¾þ¤ê£±
SET AREA COLOR 6 !3
DRAW disk WITH SCALE(0.1)*SHIFT(px(s2+1),py(s2+1)) ! ¾þ¤ê£²
SET AREA COLOR 7 !4
DRAW disk WITH SCALE(0.1)*SHIFT(px(s2+2),py(s2+2)) ! ¾þ¤ê£³
SET AREA COLOR 1
DRAW disk WITH SCALE(0.1)*SHIFT(px(s2+3),py(s2+3)) ! ¾þ¤ê£´
END PICTURE
SET TEXT FONT "£Í£Ó ÌÀÄ«",12
SET TEXT BACKGROUND "OPAQUE"
SET POINT STYLE 1
!----------------
LET t$="¥¢¥ó¥â¥Ê¥¤¥È"
LET N=101
LET xm=-0.63
LET ym=0.5
LET h=1.5
RANDOMIZE 19650218
SET WINDOW xm-h,xm+h, ym-h,ym+h
PLOT TEXT,AT xm+h*0.1,ym+h*0.85:t$& " N="& USING$("###",N)
SET POINT COLOR 44
CALL fa(N, 0.4, 0.2)
beep
!----------------
LET t$="¥·¥À¤ÎÍÕ"
LET N=19
LET xm=0.32
LET ym=0.5
LET h=0.6
RANDOMIZE 19650218
SET WINDOW xm-h,xm+h, ym-h,ym+h
DRAW axes
PLOT TEXT,AT xm+h*0.1,ym+h*0.7:t$& " N="& USING$("###",N)
PLOT TEXT,AT xm-h*0.75, ym+h*0.85:"¤·¤Ð¤é¤¯¸æÂÔ¤Á²¼¤µ¤¤¡£"
SET POINT COLOR 10
CALL fs(N, 0,0)
CALL fs(N, 0,0)
beep
PLOT TEXT,AT xm-h*0.75, ym+h*0.85:"¡¡ÉÁ²è¤Î½ªÎ»¡¡¡¡¡¡¡¡¡¡"
!------------------------------------------------------------
!¡¡Ê£¿ô¤Î½Ì¾®¥¢¥Õ¥¡¥¤¥óÊÑ´¹ (¥¢¥ó¥â¥Ê¥¤¥È)
DEF A1x(x,y)=-0.289993*x-0.001347*y+0.593333
DEF A1y(x,y)= 0.001986*x-0.196662*y-0.32 !¡¡p1=0.06124
DEF A2x(x,y)=-0.073058*x-0.024834*y+0.793333
DEF A2y(x,y)=-0.006353*x+0.285589*y-0.056667 !¡¡p2=0.022236
DEF A3x(x,y)= 0.939186*x-0.218787*y-0.046667
DEF A3y(x,y)= 0.214337*x+0.958685*y+0.01 !¡¡p3=0.916524
!------------------------------------------------------------
SUB fa(k, x,y)
IF 0< k THEN
CALL fa(k-1, A3x(x,y),A3y(x,y))
IF RND< 0.0668176 THEN CALL fa(k-1, A1x(x,y),A1y(x,y))
IF RND< 0.024261 THEN CALL fa(k-1, A2x(x,y),A2y(x,y))
END IF
PLOT POINTS: x,y
END SUB
!------------------------------------------------------------
! Ê£¿ô¤Î½Ì¾®¥¢¥Õ¥¡¥¤¥óÊÑ´¹ (¥·¥À¤ÎÍÕ)
DEF W1x(x,y)= 0.836*x+0.044*y
DEF W1y(x,y)=-0.044*x+0.836*y+0.169 ! p1=0.4
DEF W2x(x,y)=-0.141*x+0.302*y
DEF W2y(x,y)= 0.302*x+0.141*y+0.127 ! p2=0.2
DEF W3x(x,y)= 0.141*x-0.302*y
DEF W3y(x,y)= 0.302*x+0.141*y+0.169 ! p3=0.2
DEF W4x(x,y)= 0
DEF W4y(x,y)= 0.175337*y ! p4=0.2
!------------------------------------------------------------
!³ÎΨŪ¥×¥í¥Ã¥È(p1~p4)¤Ï¡¢ÊÑ·Á¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
SUB fs(k, x,y)
IF 0< k THEN
CALL fs(k-1, W1x(x,y),W1y(x,y))
IF RND< 0.3 THEN CALL fs(k-1, W2x(x,y),W2y(x,y))
IF RND< 0.3 THEN CALL fs(k-1, W3x(x,y),W3y(x,y))
IF RND< 0.3 THEN CALL fs(k-1, W4x(x,y),W4y(x,y))
END IF
PLOT POINTS: x,y
END SUB
!£²½Å¿¶»ÒChaos
LET g= 9.8 !m/s^2
LET m1=0.1 !kg
LET m2=0.1 !kg
LET L1= 5 !m
LET L2= 5 !m
!
LET dt=0.05 !sec. ±é»»¥Ô¥Ã¥Á¡£
!
LET ¦Ì2=m2/(m1+m2)
LET L21=L2/L1
DEF ss1(w2,¦È1,¦È2)=-g/L1*SIN(¦È1) -¦Ì2*L21*w2^2*SIN(¦È1-¦È2)
DEF ss2(w1,¦È1,¦È2)=-g/L2*SIN(¦È2) +w1^2*SIN(¦È1-¦È2)/L21
DEF D(¦È1,¦È2)=1-¦Ì2*COS(¦È1-¦È2)^2
DEF ¦Á1(w1,w2,¦È1,¦È2)=( ss1(w2,¦È1,¦È2) -L21*¦Ì2*COS(¦È1-¦È2)*ss2(w1,¦È1,¦È2) )/D(¦È1,¦È2)
DEF ¦Á2(w1,w2,¦È1,¦È2)=(-ss1(w2,¦È1,¦È2)*COS(¦È1-¦È2)/L21 +ss2(w1,¦È1,¦È2) )/D(¦È1,¦È2)
SUB RK(¦È1,¦È2,w1,w2)
LET w11=w1
LET w12=w2
LET ¦Á11=¦Á1(w1,w2,¦È1,¦È2)
LET ¦Á12=¦Á2(w1,w2,¦È1,¦È2)
!
LET w21=w1+¦Á11*dt/2
LET w22=w2+¦Á12*dt/2
LET ¦Á21=¦Á1(w21,w22,¦È1+w11*dt/2,¦È2+w12*dt/2)
LET ¦Á22=¦Á2(w21,w22,¦È1+w11*dt/2,¦È2+w12*dt/2)
!
LET w31=w1+¦Á21*dt/2
LET w32=w2+¦Á22*dt/2
LET ¦Á31=¦Á1(w31,w32,¦È1+w21*dt/2,¦È2+w22*dt/2)
LET ¦Á32=¦Á2(w31,w32,¦È1+w21*dt/2,¦È2+w22*dt/2)
!
LET w41=w1+¦Á31*dt
LET w42=w2+¦Á32*dt
LET ¦Á41=¦Á1(w41,w42,¦È1+w31*dt,¦È2+w32*dt)
LET ¦Á42=¦Á2(w41,w42,¦È1+w31*dt,¦È2+w32*dt)
!
LET ¦È1=¦È1+(w11+2*w21+2*w31+w41)*dt/6
LET ¦È2=¦È2+(w12+2*w22+2*w32+w42)*dt/6
LET w1=w1+(¦Á11+2*¦Á21+2*¦Á31+¦Á41)*dt/6
LET w2=w2+(¦Á12+2*¦Á22+2*¦Á32+¦Á42)*dt/6
END SUB
!----init.
LET a_1=PI*0.8 !½é´ü³ÑÅÙ£±
LET a_2=PI*0.9 !¡¡¡¡¡Á¡¡£²
LET a_3=0 !¡¡½é´ü³Ñ®ÅÙ£±
LET a_4=0 !¡¡¡¡¡¡¡¡¡Á¡¡£²
!
LET b_1=-a_1+0.001
LET b_2=-a_2
LET b_3=0
LET b_4=0
!
LET c_1=a_1
LET c_2=a_2+0.002
LET c_3=0
LET c_4=0
!
LET d_1=-a_1
LET d_2=-a_2+0.003
LET d_3=0
LET d_4=0
!
!----run
LET w=14
SET WINDOW -w,w,-w,w
SET LINE width 2 !4
SET LINE COLOR 2 !43
LET r1=SQR(m1)
LET r2=SQR(m2)
LET t0=TIME
DO
LET t=TIME
IF dt=< ABS(t-t0) THEN
SET DRAW mode hidden
CLEAR
PLOT TEXT,AT 0.25*w,0.9*w:"¥Þ¥¦¥¹ ±¦¥Ü¥¿¥ó¤Ç¡¢½ªÎ»¡£"
PLOT TEXT,AT -0.98*w,0.93*w,USING"±é»»¥Ô¥Ã¥Á=#.### ÉÃ":dt
PLOT TEXT,AT -0.98*w,0.87*w,USING"ÉÁ²è¥Ô¥Ã¥Á=#.### ÉÃ":t-t0
LET t0=t
SET AREA COLOR 15
DRAW disk WITH SCALE(3.86,4.67)
SET AREA COLOR 1
DRAW PDL1X2(a_1,a_2) WITH ROTATE(a_1)*SHIFT(-3,3)
DRAW PDL1X2(b_1,b_2) WITH ROTATE(b_1)*SHIFT(3,3)
DRAW PDL1X2(c_1,c_2) WITH ROTATE(c_1)*SHIFT(-3,-3)
DRAW PDL1X2(d_1,d_2) WITH ROTATE(d_1)*SHIFT(3,-3)
CALL RK(a_1,a_2,a_3,a_4)
CALL RK(b_1,b_2,b_3,b_4)
CALL RK(c_1,c_2,c_3,c_4)
CALL RK(d_1,d_2,d_3,d_4)
SET DRAW mode explicit
END IF
WAIT DELAY 0 !¥Î¡¼¥È¥Ñ¥½¥³¥óÅù¤Î¾ÃÈñÅÅÎϤò²¡¤¨¤ë¡£
MOUSE POLL mx,my,mlb,mrb
LOOP UNTIL mrb=1
PICTURE PDL1X2(¦È1,¦È2)
DRAW circle WITH SCALE(0.3)
DRAW PDLM(L1,r1)
DRAW PDLM(L2,r2) WITH ROTATE(¦È2-¦È1)*SHIFT(0,-L1)
END PICTURE
PICTURE PDLM(L,r)
PLOT LINES: 0,0;0,-L
DRAW disk WITH SCALE(r)*SHIFT(0,-L)
END PICTURE
!SET bitmap SIZE 600,600 !²èÌ̤òÂ礤¯¤¹¤ë
SET WINDOW -0.5,6.5, -50,5 !ɽ¼¨Îΰè
DRAW grid(1,5) !º¸Ã¼¤ÎÌÜÀ¹¤ê
FOR f=1 TO 6 !£ø¼´¤¬Âпô
PLOT TEXT ,AT f-0.3,-0.15: mid$("10 100 1k 10k 100k1M ",4*(f-1)+1,4)
NEXT f
FOR f=10 TO 100000 STEP 100 !¼þÇÈ¿ô[Hz]
CALL routine
LET vv=vo(1)/vi(1)
PLOT LINES: LOG10(f),20*LOG10(ABS(vv)); !ÍøÆÀ[dB]
NEXT f
PLOT LINES
SET TEXT COLOR 2
FOR i=5 TO -45 STEP -5 !±¦Ã¼¤Î½Ä¼´ÌÜÀ¹¤ê
PLOT TEXT ,AT 6,i: STR$(i*2)&"¡ë"
NEXT i
SET LINE COLOR 2
FOR f=10 TO 100000 STEP 100 !¼þÇÈ¿ô[Hz]
CALL routine
LET vv=vo(1)/vi(1)
PLOT LINES: LOG10(f),DEG(ATN(Im(vv)/Re(vv)))/2; !°ÌÁê¦È¡¡¢¨1/2ÇÜ
NEXT f
PLOT LINES
END
!ľÀÜË¡¤Ë¤è¤ë¹ÔÎó¤Î¸ÇÍÃͤòµá¤á¤ë
OPTION ARITHMETIC COMPLEX
LET i=SQR(-1) !µõ¿ôñ°Ì
LET cEps=1e-8 !¸íº¹¡¡¢¨Ã±ÀºÅÙ
LET N=3 !N¼¡ÀµÊý¹ÔÎó
FUNCTION tr(A(,)) !¹ÔÎóA¤Î¥È¥ì¡¼¥¹
LET t=0
FOR j=1 TO N
LET t=t+A(j,j)
NEXT j
LET tr=t
END FUNCTION
DIM c(N) !¿¹à¼° X^N+c(1)*X^(N-1)+c(2)*X^(N-2)+ ¡Ä +c(N-1)*X+c(N) ¤Î·¸¿ô
SUB DKA_00(A(),Xr()) !DKAË¡¡ÊDurand Kerner Aberth¡Ë
LET r=1 !½é´üÃͤò²¾Äꤹ¤ë
FOR j=2 TO N
LET rn=ABS(A(j))^(1/j)
if r<rn then LET r=rn
NEXT j
FOR j=1 TO N !Ⱦ·Âr¤Î±ß¤ËÅù´Ö³Ö¤ËÇÛÃÖ¤¹¤ë
LET Xr(j)=-A(1)/N+r*EXP( 2*PI*i/N *(j-3/4) ) !¥¢¡¼¥Ð¥¹¤Î½é´üÃÍ
NEXT j
FOR m=0 TO 100 !È¿Éü¡¡¢¨Ä´À°Í×
LET mfx=0
LET maj=0
FOR j=1 TO N
LET Xk=1
LET fx=1
FOR w=1 TO N
LET fx=fx*Xr(j)+A(w)
IF w<>j THEN LET Xk=Xk*(Xr(j)-Xr(w))
NEXT w
LET Xr(j)=Xr(j)-fx/Xk
IF mfx<ABS(fx) THEN LET mfx=ABS(fx)
IF maj<ABS(fx/Xk) THEN LET maj=ABS(fx/Xk)
NEXT j
IF mfx<cEps AND maj<cEps THEN EXIT FOR !¼ý«¤·¤¿¤é
NEXT m
END SUB
!-------------------- ¤³¤³¤Þ¤Ç¤¬¥µ¥Ö¥ë¡¼¥Á¥ó
DIM A(N,N) !¹ÔÎóA
!DATA 1,0,0 !¦Ë=1¡Ê£³½Åº¬¡Ë
!DATA 0,1,1
!DATA 0,0,1
!DATA 0,1,1 !¦Ë=2,-1¡Ê½Åº¬¡Ë
!DATA 1,0,1
!DATA 1,1,0
!DATA 3,0,0 !¦Ë=3,¡Þi
!DATA 0,2,-5
!DATA 0,1,-2
DATA 2,1,-1 !¦Ë=3,2,1
DATA 0,3,0
DATA 0,2,1
MAT READ A
MAT PRINT A;
!n¼¡ÀµÊý¹ÔÎóA¤Î¸ÇÍ¿¹à¼° det(tE-A)=t^n+c1*t^(n-1)+ ¡Ä + cn ¤òµá¤á¤ë¡£
DIM X(N,N),cE(N,N)
MAT X=IDN !frameˡ
FOR k=1 TO N
MAT X=A*X
LET c(k)=-tr(X)/k
MAT cE=(c(k))*IDN
MAT X=X+cE
NEXT k
MAT PRINT c;
!¥Ë¥å¡¼¥È¥óË¡¤Ê¤É¤Ç²ò¤¯¡£²ò¤¬¸ÇÍÃͤˤʤ롣
DIM lmd(N)
CALL DKA_00(c,lmd)
FOR k=1 TO N
PRINT "¸ÇÍÃÍ=";lmd(k)
NEXT k
!¢¨N¸Äµá¤Þ¤Ã¤¿¾ì¹ç¤Î¸¡»»
LET s=1
FOR k=1 TO N
LET s=s*lmd(k)
NEXT k
PRINT s, DET(A) !¸ÇÍÃͤÎÀÑ=¹ÔÎó¤Î¹ÔÎó¼°¡¡¦°¦Ëi=|A|
LET s=0
FOR k=1 TO N
LET s=s+lmd(k)
NEXT k
PRINT s, tr(A) !¸ÇÍÃͤÎÏÂ=¹ÔÎó¤Î¥È¥ì¡¼¥¹¡¡¦²¦Ëi=trA
END
LET N=4 !N¹ÔNÎó
LET a=-2 !Àޤꤿ¤¿¤à°ÌÃÖ(a,b)
LET b=2
DATA 0,1,1,0 !£Ñ¥Ñ¥¿¡¼¥ó¡¡¢¨1:ɽ¡¢0:΢
DATA 0,1,0,1
DATA 1,0,1,0
DATA 1,1,0,0
DIM M(N,N)
MAT READ M
FOR y=1 TO N !¹Ô
FOR x=1 TO N !Îó
IF MOD(ABS(x-a)+ABS(y-b),2)=1 THEN !³Ê»Ò¾å¤Ç¤Îµ÷Î¥¡¡¢¨1:ȿž¡¢0:¤½¤Î¤Þ¤Þ
LET M(y,x)=1-M(y,x) !ÏÀÍýÈÝÄê
END IF
PRINT M(y,x); !¡Ö£°¤¬£´¤Ä¡×¤Þ¤¿¤Ï¡Ö£±¤¬£´¤Ä¡×¤Î°ÌÃÖ
NEXT x
PRINT
NEXT y
END
REM ½½¿ÊBASICźÉÕ"\BASICw32\SAMPLE\COMBINAT.BAS"¤è¤ê
REM 1¡Án¤Î½¸¹ç¤«¤ér¸Ä¤òÁª¤ÖÁȹ礻¤òÀ¸À®¤¹¤ë¡£ÇÛÎócom(,)
EXTERNAL SUB combination(a(),n,k,r,com(,),count)
! k°Ê¹ß¤Î¿ô¤«¤ér¸Ä¤òÁªÂò¤¹¤ë
IF r=0 THEN
LET count=count+1
LET ri=1
FOR i=1 TO n
IF a(i)=1 THEN
LET com(count,ri)=i
LET ri=ri+1
END IF
NEXT i
ELSE
FOR i=k TO n-r+1
LET a(i)=1
CALL combination(a,n,i+1,r-1,com,count)
LET a(i)=0
NEXT i
END IF
END SUB
!Âǽç¹Í»¡¤Î¤¿¤á¤Î¥·¥ß¥å¥ì¡¼¥·¥ç¥ó
DATA 0.2, 0.2, 0.3, 0.3, 0.3, 0.2, 0.2, 0.1, 0.1
!DATA 0.1, 0.2, 0.2, 0.3, 0.2, 0.1, 0.3, 0.2, 0.3
!DATA 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2
DIM D(9) !£¹¿Íʬ¤ÎÂÇΨ
MAT READ D
RANDOMIZE
LET N=5000 !»î¹ç¿ô
FOR x=1 TO N
DIM SM(N) !Áí¹çÆÀÅÀ
LET P=1 !Âǽç
FOR w=1 TO 9 !£¹²ó¤Þ¤Ç
LET B=0 !ÎݤξõÂÖ
LET S1=0 !ÆÀÅÀ
LET O=0
DO UNTIL O=3 !£³¥¢¥¦¥È¤Þ¤Ç
!PRINT P;"ÈÖÂǼԡ§";
IF RND<D(P) THEN !¥Ò¥Ã¥È¤Ê¤é
LET t=INT(RND*10)+1 !ĹÂÇΨ¤Ê¤É¡¡¢¨£±¡Á10
SELECT CASE t
CASE 1,2,3,4
LET v=1
CASE 5,6,7
LET v=2
CASE 8,9
LET v=3
CASE ELSE
LET v=4
END SELECT
!PRINT v;"ÎÝÂÇ", !£±¡Á£´
LET B=B*10+1 !vÎÝÂǤÇÁö¼Ô¤òÁ÷¤ë
LET S1=S1+INT(B/10^3)
LET B=MOD(B,10^3)
FOR i=0 TO v-2
LET B=B*10
LET S1=S1+INT(B/10^3)
LET B=MOD(B,10^3)
NEXT i
ELSE
LET O=O+1
!PRINT "¥¢¥¦¥È",
END IF
!PRINT USING "# %%%": S1,B !ÎݤξõÂÖ
LET P=P+1 !¼¡¤Ø
IF P>9 THEN LET P=1
LOOP
!PRINT w;"²ó";S1;"ÅÀ"
!PRINT
LET SM(w)=SM(w)+S1
NEXT w
NEXT x
LET S=0 !ÆÀÅÀ¤ÎʬÉÛ
FOR w=1 TO 9
PRINT w;"²ó";SM(w)/N;"ÅÀ"
LET S=S+SM(w)
NEXT w
PRINT "Áí¹çÆÀÅÀ=";S/N
END
DECLARE EXTERNAL SUB perm
PUBLIC NUMERIC player,games,rank,total_point,worst_point
PUBLIC NUMERIC ave(9),best_order(100,9),best_point(100)
PRINT TIME$
LET t=TIME
LET player=9 ! 9!=362880Ä̤ê
LET games=1000 ! »î¹ç¿ô
LET rank=100 ! ¥é¥ó¥¯
MAT READ ave
DATA .460,.420,.380,.340,.300,.260,.220,.180,.140
!DATA .380,.360,.340,.320,.300,.280,.260,.240,.220
DIM a(player)
FOR i=1 TO player
LET a(i)=i
NEXT i
MAT best_order=ZER
MAT best_point=ZER
LET total_point=0
LET worst_point=10*games
CALL perm(a,1)
FOR i=1 TO rank
PRINT USING "No## Âǽç" : i;
FOR j=1 TO player
PRINT best_order(i,j);
NEXT j
PRINT USING " ´üÂÔÃÍ-%.### ÅÀ":best_point(i)/games
NEXT i
PRINT "ºÇÄã´üÂÔÃÍ =";worst_point/games;"ÅÀ"
PRINT "Ê¿¶Ñ =";total_point/(games*FACT(player));"ÅÀ"
PRINT TIME-t;"sec"
END
EXTERNAL SUB simulation(order())
LET sum_point=0
FOR i=1 TO games
LET at_bat=0
FOR inning=1 TO 9 ! 9²ó
LET out_count=0
LET hit=0
DO
IF ave(order(MOD(at_bat,player)+1))>RND THEN
LET hit=hit+1
IF hit>=3 THEN LET sum_point=sum_point+1
ELSE
LET out_count=out_count+1
END IF
LET at_bat=at_bat+1
LOOP UNTIL out_count=3
NEXT inning
NEXT i
LET total_point=total_point+sum_point
IF sum_point>best_point(rank) THEN ! ¥é¥ó¥¯ÉÕ¤±
LET best_point(rank)=sum_point
FOR j=1 TO player
LET best_order(rank,j)=order(j)
NEXT j
FOR i=rank TO 2 STEP -1
IF best_point(i)>best_point(i-1) THEN
SWAP best_point(i),best_point(i-1)
FOR j=1 TO player
SWAP best_order(i,j),best_order(i-1,j)
NEXT j
ELSE
EXIT SUB
END IF
NEXT i
ELSEIF sum_point<worst_point THEN
LET worst_point=sum_point
END IF
END SUB
REM ½½¿ÊBASICźÉÕ"\BASICw32\SAMPLE\PERMUTAT.BAS"¤è¤ê
REM 1¡Án¤Î½çÎó¤ò¼½ñ¼°½ç½ø¤ÇÀ¸À®¤¹¤ë¡£
EXTERNAL SUB perm(a(),n)
DECLARE EXTERNAL SUB simulation
IF n=player THEN
CALL simulation(a)
ELSE
FOR i=n TO player
LET t=a(i)
FOR j=i-1 TO n STEP -1
LET a(j+1)=a(j)
NEXT j
LET a(n)=t
CALL perm(a,n+1)
LET t=a(n)
FOR j=n TO i-1
LET a(j)=a(j+1)
NEXT j
LET a(i)=t
NEXT i
END IF
END SUB
! euler function
!------------------
INPUT PROMPT "n=":M
LET Mw=M
LET Phi=1
DO
LET P=prmdiv(Mw)
LET Phi=Phi*(P-1)
LET Mw=INT(Mw/P)
DO WHILE MOD(Mw,P)=0
LET Phi=Phi*P
LET Mw=INT(Mw/P)
LOOP
LOOP UNTIL Mw=1
PRINT Phi
FUNCTION prmdiv(Mw) !£±¡ã¤ÎºÇ¾®¤ÎÌó¿ô
FOR i=2 TO Mw
IF MOD(Mw,i)=0 THEN EXIT FOR
NEXT i
LET prmdiv=i
END FUNCTION
FUNCTION prmdiv(Mw) !£±¡ã¤ÎºÇ¾®¤ÎÌó¿ô
IF MOD(Mw,2)=0 THEN
LET prmdiv=2
EXIT FUNCTION
ELSEIF MOD(Mw,3)=0 THEN
LET prmdiv=3
EXIT FUNCTION
END IF
FOR i=5 TO SQR(Mw) STEP 6
IF MOD(Mw,i)=0 THEN
LET prmdiv=i
EXIT FUNCTION
ELSEIF MOD(Mw,i+2)=0 THEN
LET prmdiv=i+2
EXIT FUNCTION
END IF
NEXT i
LET prmdiv=Mw
END FUNCTION
!¤Ù¤¾èË¡¤Ë¤è¤ë¹ÔÎó¤Î¸ÇÍÃͤȸÇÍ¥Ù¥¯¥È¥ë¤òµá¤á¤ë
!¢¨¸ÇÍÃͤ¬£°¡¢½ÅÊ£¤¹¤ë¾ì¹ç¤ÏŬÍѤǤ¤Ê¤¤¡£
!¢¨¼Â¿ô¤Î¸ÇÍÃͤΤߡ£µõ¿ô¤ò´Þ¤à²ò¤ÏÆÀ¤é¤ì¤Ê¤¤¡£
!Ax=¦ËIx¡¢¦Ë:¸ÇÍÃÍ¡¢x:¸ÇÍ¥Ù¥¯¥È¥ë
LET N=3 !N¼¡ÀµÊý¹ÔÎó
DATA 2,1,-1 !¦Ë=3,2,1
DATA 0,3,0
DATA 0,2,1
!DATA 0,1,1 !¦Ë=2,1,0
!DATA -4,4,2
!DATA 4,-3,-1
!DATA 1,0,0 !¦Ë=1¡Ê£³½Åº¬¡Ë
!DATA 0,1,1
!DATA 0,0,1
DIM A(N,N) !¹ÔÎóA
MAT READ A
MAT PRINT A;
LET cEps=1e-6 !¸íº¹¡¡¢¨Ä´À°Íס¢Ã±ÀºÅÙ
DIM u(N) !¸ÇÍ¥Ù¥¯¥È¥ë
DIM AA(N,N) !ºî¶ÈÍÑ
MAT AA=A
FOR s=1 TO N !sÈÖÌÜ
CALL EigenPower(N,AA, lambda,u)
PRINT "¸ÇÍÃÍ=";lambda
PRINT "¸ÇÍ¥Ù¥¯¥È¥ë"
MAT PRINT u;
FOR i=1 TO N !»Äº¹¹ÔÎó¤òµá¤á¤Æ¡¢¼¡¤Ø
FOR j=1 TO N
LET AA(i,j)=AA(i,j)-lambda*u(i)*u(j)
NEXT j
NEXT i
NEXT s
DEF norm(v())=SQR(DOT(v,v)) !¥Î¥ë¥à
SUB EigenPower(N,A(,), lambda,u()) !¸ÇÍÃÍ¡ÊÀäÂÐÃͺÇÂç¡Ë¡¢¸ÇÍ¥Ù¥¯¥È¥ë¤òµá¤á¤ë
DIM u0(100),u2(100) !¢¨ºÇÂç100¼¡
MAT u=CON !½é´üÃÍ¡¡¢¨¥Î¥ë¥à¤¬£±
MAT u=(1/norm(u))*u
LET cMax=100
FOR i=1 TO cMax !ºÇÂç²ó¿ô¤Þ¤Ç·«¤êÊÖ¤¹
MAT u0=u !ľÁ°¤Îu
MAT u=A*u0
WHEN EXCEPTION IN
MAT u=(1/norm(u))*u !Àµµ¬²½¤¹¤ë
USE
PRINT "£°¥Ù¥¯¥È¥ë¤Ë¤Ê¤ê¤Þ¤·¤¿¡£"
STOP
END WHEN
MAT u2=u-u0 !¼ý«¤·¤¿¤«³Îǧ¤¹¤ë
IF norm(u2)<cEps THEN EXIT FOR
MAT u2=u+u0
IF norm(u2)<cEps THEN EXIT FOR
NEXT i
IF i>cMax THEN
PRINT "¼ý«¤·¤Þ¤»¤ó¡£"
STOP
END IF
MAT u2=A*u
LET lambda=DOT(u2,u)/DOT(u,u) !¸ÇÍÃÍ
END SUB
END
!Âǽç¹Í»¡¤Î¤¿¤á¤Î¥·¥ß¥å¥ì¡¼¥·¥ç¥ó
DATA 0.2, 0.2, 0.3, 0.3, 0.3, 0.2, 0.2, 0.1, 0.1
!DATA 0.1, 0.2, 0.2, 0.3, 0.2, 0.1, 0.3, 0.2, 0.3
!DATA 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2
DIM D(9) !£¹¿Íʬ¤ÎÂÇΨ
MAT READ D
RANDOMIZE
LET N=10 !»î¹ç¿ô¡¡¢¨Ä´À°Í×
FOR x=1 TO N
PRINT !<----- ¤³¤³
PRINT "***";x;"»î¹çÌÜ ***" !<----- ¤³¤³
DIM SM(N) !Áí¹çÆÀÅÀ
LET P=1 !Âǽç
FOR w=1 TO 9 !£¹²ó¤Þ¤Ç
LET B=0 !ÎݤξõÂÖ
LET S1=0 !ÆÀÅÀ
LET O=0
DO UNTIL O=3 !£³¥¢¥¦¥È¤Þ¤Ç
PRINT P;"ÈÖÂǼԡ§"; !<----- ¤³¤³
IF RND<D(P) THEN !¥Ò¥Ã¥È¤Ê¤é
LET t=INT(RND*10)+1 !ĹÂÇΨ¤Ê¤É¡¡¢¨£±¡Á10
SELECT CASE t
CASE 1,2,3,4
LET v=1
CASE 5,6,7
LET v=2
CASE 8,9
LET v=3
CASE ELSE
LET v=4
END SELECT
PRINT v;"ÎÝÂÇ", !£±¡Á£´ <----- ¤³¤³
LET B=B*10+1 !vÎÝÂǤÇÁö¼Ô¤òÁ÷¤ë
LET S1=S1+INT(B/10^3)
LET B=MOD(B,10^3)
FOR i=0 TO v-2
LET B=B*10
LET S1=S1+INT(B/10^3)
LET B=MOD(B,10^3)
NEXT i
ELSE
LET O=O+1
PRINT "¥¢¥¦¥È", !<----- ¤³¤³
END IF
PRINT USING "# %%%": S1,B !ÎݤξõÂÖ <----- ¤³¤³
LET P=P+1 !¼¡¤Ø
IF P>9 THEN LET P=1
LOOP
PRINT w;"²ó";S1;"ÅÀ" !<----- ¤³¤³
PRINT !<----- ¤³¤³
LET SM(w)=SM(w)+S1
NEXT w
NEXT x
PRINT
LET S=0 !ÆÀÅÀ¤ÎʬÉÛ
FOR w=1 TO 9
PRINT w;"²ó";SM(w)/N;"ÅÀ"
LET S=S+SM(w)
NEXT w
PRINT "Áí¹çÆÀÅÀ=";S/N
END
DEF f(x)=x^2 !´Ø¿ôy=x^2
DEF g(x,a,b)=(f(b)-f(a))/(b-a)*(x-a)+f(a) !ÅÀA¤ÈÅÀB¤òÄ̤ëľÀþ
LET a=-2
LET b=4
SET bitmap SIZE 300,600
SET WINDOW -10,10,-20,20 !ɽ¼¨Îΰè
DRAW grid !ºÂɸ
FOR x=-10 TO 10 STEP 0.2 !ÊüʪÀþy=x^2¤òÉÁ¤¯
PLOT LINES: x,f(x);
NEXT x
PLOT LINES
SUB ten(x,y,s$)
PLOT TEXT ,AT x+0.4,y: s$
DRAW disk WITH SCALE(0.2)*SHIFT(x,y)
END SUB
CALL ten(-a,f(-a),"A")
CALL ten(b,f(b),"B")
FOR x=-10 TO 10 STEP 0.2 !ľÀþ¤òÉÁ¤¯
PLOT LINES: x,g(x,-a,b);
NEXT x
PLOT LINES
CALL ten(0,g(0,-a,b),"P") !yÀÚÊÒ
PRINT g(0,-a,b), a*b !¸¡»»
DEF h(a,b)=(f(b)-f(a))/(b-a) !·¹¤
PRINT h(a,b), a+b
END
10 DEF f(x)=x^2 !´Ø¿ôy=x^2
20 DEF g(x,a,b)=(f(b)-f(a))/(b-a)*(x-a)+f(a) !ÅÀA¤ÈÅÀB¤òÄ̤ëľÀþ
30 INPUT PROMPT "2¿ô¤òÁª¤Ö":x,y
40 LET x1=INT(LOG10(x))
50 LET y1=INT(LOG10(y))
60 LET x=x/10^x1
70 LET y=y/10^y1
80 LET a=x
90 LET b=y
100 IF a>b THEN LET t=a ELSE LET t=b
110 SET bitmap SIZE 300,600
120 SET WINDOW -(t+1),t+1,-2,(t+1)^2+5 !ɽ¼¨Îΰè
130 DRAW grid !ºÂɸ
140 FOR x=-10 TO 10 STEP 0.2 !ÊüʪÀþy=x^2¤òÉÁ¤¯
150 PLOT LINES: x,f(x);
160 NEXT x
170 PLOT LINES
180 SUB ten(x,y,s$)
190 PLOT TEXT ,AT x+0.4,y: s$
200 DRAW disk WITH SCALE(0.2)*SHIFT(x,y)
210 END SUB
220 CALL ten(-a,f(-a),"A")
230 CALL ten(b,f(b),"B")
240 FOR x=-10 TO 10 STEP 0.2 !ľÀþ¤òÉÁ¤¯
250 PLOT LINES: x,g(x,-a,b);
260 NEXT x
270 PLOT LINES
280 CALL ten(0,g(0,-a,b),"P") !yÀÚÊÒ
290 PRINT "YÀÚÊÒ¤ÎÃÍ";g(0,-a,b);
300 PRINT "·×»»·ë²Ì"; a*b*10^(x1+y1) !¸¡»»
310 DEF h(a,b)=(f(b)-f(a))/(b-a) !·¹¤
320 !PRINT h(a,b), a+b
330 END
> !ÁÇ¿ô¤ÎÀ¸À®
> PRINT prm(100) !541
> PRINT nxtprm(999) !prm(1000)=7919
> !PRINT nxtprm(9999) !prm(10000)=104729
>
> EXTERNAL FUNCTION prm(n) !nÈÖÌܤÎÁÇ¿ô¡¡¢¨n¤Ï£±°Ê¾å
> DIM prime(n) !ÁÇ¿ôÎó
> LET prime(1)=2 !£±ÈÖÌܤϣ²
> LET k=2 !kÈÖÌÜ
> LET x=1 !¸¡¾Ú¤¹¤ë¼«Á³¿ô
> DO WHILE k<=n !NÈÖÌܤޤÇ
> LET x=x+2 !´ñ¿ô¤¬ÂоÝ
> LET j=1 !¸«¤Ä¤«¤Ã¤¿ÁÇ¿ô¤ÎÇÜ¿ô¤«¤É¤¦¤«³Îǧ¤¹¤ë
> DO WHILE j<k AND MOD(x,prime(j))<>0 !ÇÜ¿ô¤Ê¤éÅÓÃæ¤Ç½ªÎ»
> LET j=j+1
> LOOP
> IF j=k THEN !¿·¤·¤¯¸«¤Ä¤«¤Ã¤¿ÁÇ¿ô¤òµÏ¿¤¹¤ë
> LET prime(k)=x
> LET k=k+1
> END IF
> LOOP
> LET prm=prime(n)
> END FUNCTION
>
> EXTERNAL FUNCTION nxtprm(n) !n+1ÈÖÌܤÎÁÇ¿ô
> LET nxtprm=prm(n+1)
> END FUNCTION
EXTERNAL FUNCTION prm(n) ! nÈÖÌܤÎÁÇ¿ô
DIM prime(n)
FOR i=1 TO MIN(n,10)
READ prime(i)
NEXT i
DATA 2,3,5,7,11,13,17,19,23,29
FOR i=11 TO n
LET m30=MOD(prime(i-1),30)
IF m30=1 OR m30=23 THEN LET a=prime(i-1)+6 ELSE LET a=prime(i-1)-2*MOD(m30,3)+6
DO
LET sqra=SQR(a)
FOR j=4 TO i-1
IF MOD(a,prime(j))=0 THEN EXIT FOR
IF prime(j)>=sqra THEN
LET prime(i)=a
EXIT DO
END IF
NEXT j
LET m30=MOD(a,30)
IF m30=1 OR m30=23 THEN LET a=a+6 ELSE LET a=a-2*MOD(m30,3)+6
LOOP
NEXT i
LET prm=prime(n)
END FUNCTION
EXTERNAL FUNCTION nxtprm(x) !x¤è¤êÂ礤¤ÁÇ¿ô¤ÎºÇ¾®¤Î¤â¤Î
DIM prime(x)
FOR i=1 TO 10 !ºÇ½é¤Î10¸Ä
READ prime(i)
IF x<prime(i) THEN
LET nxtprm=prime(i)
EXIT FUNCTION
END IF
NEXT i
DATA 2,3,5,7,11,13,17,19,23,29
FOR i=11 TO INT(x) !11¸ÄÌܰʹß
LET m30=MOD(prime(i-1),30)
IF m30=1 OR m30=23 THEN LET a=prime(i-1)+6 ELSE LET a=prime(i-1)-2*MOD(m30,3)+6
DO
LET sqra=SQR(a)
!!!LET sqra=INTSQR(a) !<----- ¢¨ÍÍý¿ô¥â¡¼¥É
FOR j=4 TO i-1
IF MOD(a,prime(j))=0 THEN EXIT FOR
IF prime(j)>=sqra THEN
LET prime(i)=a
EXIT DO
END IF
NEXT j
LET m30=MOD(a,30)
IF m30=1 OR m30=23 THEN LET a=a+6 ELSE LET a=a-2*MOD(m30,3)+6
LOOP
IF x<prime(i) THEN
LET nxtprm=prime(i)
EXIT FUNCTION
END IF
NEXT i
PRINT "¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£"
STOP
END FUNCTION
!ÁÇ¿ô¤Î¸Ä¿ô
!PRINT fnPrimePi(77777)
!¸¶»Ïº¬ genshi3
FOR LP=1 TO 100
LET P=prm(LP) !ºÇ½é¤Î100¸Ä¤ÎÁÇ¿ô¤ËÂФ·¤Æ
PRINT USING "##### ### |": P,fnGenshi(P);
IF MOD(LP,5)=0 THEN PRINT
NEXT LP
PRINT
!¸¶»Ïº¬ genshi2
FOR LP=1 TO 100
LET P=prm(LP) !ºÇ½é¤Î100¸Ä¤ÎÁÇ¿ô¤ËÂФ·¤Æ
LET G=1
IF P<>2 THEN
50 LET G=G+1
LET W=1
FOR i=1 TO P-2
LET W=MOD(W*G,P)
IF W=1 THEN GOTO 50
NEXT i
END IF
PRINT USING "##### ### |": P,G;
IF MOD(LP,5)=0 THEN PRINT
NEXT LP
PRINT
END
EXTERNAL FUNCTION fnPrimePi(X) !¼Â¿ôx¤ËÂФ·x°Ê²¼¤ÎÁÇ¿ô¤Î¸Ä¿ô
LET S=1
LET E=10000 !100,000°Ê²¼¤ÎÁÇ¿ô¤Ï10,000¸Ä̤Ëþ¤À¤«¤é¡¡¢¨
DO WHILE E>S+1
LET K=INT((S+E)/2) !£²Ê¬Ãµº÷
IF prm(K)<=X THEN LET S=K ELSE LET E=K
LOOP
LET fnPrimePi=S
END FUNCTION
EXTERNAL FUNCTION fnGenshi(P) !¸¶»Ïº¬
LET G=1
LET N=P-1
IF P<>2 THEN
180 LET G=G+1
LET Nw=N
DO
LET Div=prmdiv(Nw)
DO WHILE MOD(Nw,Div)=0
LET Nw=INT(Nw/Div)
LOOP
IF modpow(G,INT(N/Div),P)=1 THEN GOTO 180
LOOP UNTIL Nw=1
END IF
LET fnGenshi=G
END FUNCTION
OPTION BASE 0
SET WINDOW 0,500, 500,0
!
LET Xmax=90
LET Ymax=90
LET MaxCan=INT(Xmax*Ymax/4) !¡¡must Ymax<=Xmax
LET Bsize=4
LET Xoff=INT((500-Xmax*Bsize)/2)
LET Yoff=INT((500-Ymax*Bsize)/3) ! 20
DIM Map_(Xmax,Ymax)
DIM CanX_(MaxCan),CanY_(MaxCan),DirX_(MaxCan),DirY_(MaxCan)
RANDOMIZE
!
FOR I=0 TO 1
FOR J=0 TO Ymax
LET Map_(I,J)=1
LET Map_(Xmax-I,J)=1
NEXT J
NEXT I
FOR J=0 TO 1
FOR I=0 TO Xmax
LET Map_(I,J)=1
LET Map_(I,Ymax-J)=1
NEXT I
NEXT J
LET X=2
FOR Y=4 TO Ymax-2
CALL DOT_(X,Y)
NEXT Y
LET X=Xmax-2
FOR Y=2 TO Ymax-4
CALL DOT_(X,Y)
NEXT Y
LET Y=2
FOR X=2 TO Xmax-2
CALL DOT_(X,Y)
NEXT X
LET Y=Ymax-2
FOR X=2 TO Xmax-2
CALL DOT_(X,Y)
NEXT X
LET Ncan=0
FOR I=2 TO INT(Xmax/(2)) -2
CALL InsCan_(I*2,2)
CALL InsCan_(I*2,Ymax-2)
NEXT I
FOR J=2 TO INT(Ymax/(2)) -2
CALL InsCan_(2,J*2)
CALL InsCan_(Xmax-2,J*2)
NEXT J
LET Ndir=4
LET DirX_(1)=2
LET DirY_(1)=0
LET DirX_(2)=0
LET DirY_(2)=2
LET DirX_(3)=-2
LET DirY_(3)=0
LET DirX_(4)=0
LET DirY_(4)=-2
DO WHILE Ncan>0
CALL Selcan_(I,J)
DO
LET Ndir=4
DO
CALL SelDir_(DI,DJ)
LET Ok=1-Map_(I+DI,J+DJ)
LOOP UNTIL Ok<>0 OR Ndir=0
IF Ok<>0 THEN
CALL DOT_(I+INT(DI/(2)),J+INT(DJ/(2)) )
LET I=I+DI
LET J=J+DJ
CALL DOT_(I,J)
CALL InsCan_(I,J)
END IF
LOOP UNTIL NOT Ok<>0
LOOP
SUB DOT_(X,Y)
LET Map_(X,Y)=1
! SET AREA COLOR 5
PLOT AREA:
Bsize*X+Xoff,Bsize*Y+Yoff;Bsize*X+Xoff+Bsize-1,Bsize*Y+Yoff;Bsize*X+Xoff+Bsize-1,Bsize*Y+Yoff+Bsize-1;Bsize*X+Xoff,Bsize*Y+Yoff+Bsize-1
END SUB
SUB InsCan_(I,J)
LET Ncan=Ncan+1
LET CanX_(Ncan)=I
LET CanY_(Ncan)=J
END SUB
SUB Selcan_(I,J)
local R
LET R=int(Ncan*rnd)+1
LET I=CanX_(R)
LET J=CanY_(R)
LET CanX_(R)=CanX_(Ncan)
LET CanY_(R)=CanY_(Ncan)
LET Ncan=Ncan-1
END SUB
SUB SelDir_(I,J)
local R
LET R=int(Ndir*rnd)+1
LET I=DirX_(R)
LET J=DirY_(R)
LET DirX_(R)=DirX_(Ndir)
LET DirY_(R)=DirY_(Ndir)
LET DirX_(Ndir)=I
LET DirY_(Ndir)=J
LET Ndir=Ndir-1
END SUB
SUB Routine_
LET I=K-J
IF fnCheck(I,J)< 3 THEN EXIT SUB
LET Ii=I
LET Jj=J
DO
CALL Fil_(Ii,Jj)
IF Map_(Ii-1,Jj)=0 THEN
LET Ii=Ii-1
ELSEIF Map_(Ii,Jj+1)=0 THEN
LET Jj=Jj+1
ELSEIF Map_(Ii+1,Jj)=0 THEN
LET Ii=Ii+1
ELSEIF Map_(Ii,Jj-1)=0 THEN
LET Jj=Jj-1
END IF
LOOP UNTIL fnCheck(Ii,Jj)<>3
END SUB
SUB Fil_(X,Y)
LET Map_(X,Y)=1
SET AREA COLOR 4 !3
PLOT AREA:
Bsize*X+Xoff,Bsize*Y+Yoff;Bsize*X+Xoff+Bsize-1,Bsize*Y+Yoff;Bsize*X+Xoff+Bsize-1,Bsize*Y+Yoff+Bsize-1;Bsize*X+Xoff,Bsize*Y+Yoff+Bsize-1
END SUB
DECLARE EXTERNAL SUB sort
PUBLIC NUMERIC c
LET tt=TIME
LET s=4
LET n=13
LET c=s*n
DIM check(c),card(c),position(n,s),face(n),total(0 TO n-1),count(0 TO n-1)
LET test=100000 ! 100000¤Ç125ÉÃ
FOR t=1 TO test
CALL prep
CALL play
NEXT t
LET cc=0
PRINT " ÁÈ ³ÎΨ Ê¿¶ÑËç¿ô"
FOR i=0 TO n-1
PRINT USING " ## .##### ##.##Ëç" : i,total(i)/test,count(i)/total(i)
LET cc=cc+count(i)
NEXT i
PRINT USING " ##.##Ëç" : cc/test
PRINT INT(TIME-tt);"sec"
SUB prep
FOR i=1 TO c
LET check(i)=RND
NEXT i
CALL sort(check,card)
!MAT PRINT card;
FOR j=1 TO s
FOR i=1 TO n
LET position(i,j)=card((j-1)*n+i)
NEXT i
NEXT j
!MAT PRINT position;
END SUB
SUB play
MAT face=ZER
LET cc=0
CALL open_card(n)
!MAT PRINT face;
LET f=0
FOR i=1 TO n-1
IF face(i)=s THEN LET f=f+1
NEXT i
LET total(f)=total(f)+1
LET count(f)=count(f)+cc
END SUB
SUB open_card(nn)
LET cc=cc+1
LET look=position(nn,1)
FOR j=1 TO s-1
LET position(nn,j)=position(nn,j+1)
NEXT j
LET p=MOD(look,n)+1
!PRINT p;
LET face(p)=face(p)+1
IF face(n)=s THEN EXIT SUB
CALL open_card(p)
END SUB
END
REM ½½¿ÊBASICźÉÕ"\BASICw32\Library\SORT2.LIB"¤è¤ê
! ix¤Ë¤Ïm¤È²¼¸Â¡¤¾å¸Â¤ò°ìÃפµ¤»¤¿¶õ¤ÎÇÛÎó¤ò»ØÄꤹ¤ë¡£
! m¤Ï»²¾È¤µ¤ì¤ë¤Î¤ß¡£
! ix¤Ëm¤Îź»ú¤òÂ礤µ¤Î½ç¤Ëʤ٤ÆÊÖ¤¹¡£
! ¤Ä¤Þ¤ê¡¤m(ix(1))¡åm(ix(2))¡åm(ix(3))¡åŽ¥Ž¥Ž¥¤È¤Ê¤ë¡£
EXTERNAL SUB sort(m(),ix())
FOR i=1 TO c
LET ix(i)=i
NEXT i
CALL q_sort(m,ix,1,c)
END SUB
EXTERNAL SUB q_sort(m(),a(),l,r)
IF r<=l THEN
EXIT SUB
ELSE
LET i=l-1
LET j=r
LET pv=m(a(r))
DO
DO
LET i=i+1
LOOP UNTIL pv<=m(a(i))
DO
LET j=j-1
LOOP UNTIL j<=i OR m(a(j))<=pv
IF j<=i THEN EXIT DO
LET t=a(i)
LET a(i)=a(j)
LET a(j)=t
LOOP
LET t=a(i)
LET a(i)=a(r)
LET a(r)=t
CALL q_sort(m,a,l,i-1)
CALL q_sort(m,a,i+1,r)
END IF
END SUB
!¥¢¥Ê¥í¥°»þ·×
SET WINDOW -1.2,1.2,-1.2,1.2 !ɽ¼¨Îΰè
SET TEXT JUSTIFY "center","half" !ʸ»úɽ¼¨¤Î½ñ¼°
DO
LET t$=TIME$ !»þ¹ï¤òhh:mm:ss·Á¼°¤ÇÆÀ¤ë
LET h=VAL(t$(1:2)) !¿ôÃͤØ
LET m=VAL(t$(4:5))
LET s=VAL(t$(7:8))
SET DRAW mode hidden !¤Á¤é¤Ä¤ßËɻߡʳ«»Ï¡Ë
CLEAR
FOR i=1 TO 12 !ʸ»úÈ×
LET th=PI/2-2*PI*i/12 !£Ù¼´¤«¤é»þ·×¤Þ¤ï¤ê
PLOT TEXT ,AT COS(th),SIN(th): STR$(i) !±ß¼þ¾å
NEXT i
LET th=PI/2-2*PI*(h + m/60)/12 !»þ¿Ë
PLOT LINES: 0,0; 0.6*COS(th),0.6*SIN(th)
LET th=PI/2-2*PI*m/60 !ʬ¿Ë
PLOT LINES: 0,0; 0.9*COS(th),0.9*SIN(th)
LET th=PI/2-2*PI*s/60 !ÉÿË
PLOT LINES: 0,0; 0.8*COS(th),0.8*SIN(th)
SET DRAW mode explicit !¤Á¤é¤Ä¤ËɻߡʽªÎ»¡Ë
LOOP
END
¾å½ñ¤¤»¤Æ¤¤¤¿¤À¤¤Þ¤·¤¿¡£
Ä´¤Ù¤¿¤é1ʬ´Ö¤ËÌó8200²ó¤ÎÉÁ²è¤ò¤·¤Æ¤¤¤¿¤Î¤Ç¡¢Éäι¹¿·¤¬¤¢¤Ã¤¿¤È¤¤ËÉÁ²è¤¹¤ë¤è¤¦¤Ë¤·¤Þ¤·¤¿¡£
ʸ»úÈ×Éôʬ¤âLOOP¤«¤é½Ð¤·¤ÆÉÁ²è»þ´Ö¤òÀáÌó¡£
Ĺ¿Ë¡¦Ã»¿Ë¤ò³¨ÄêµÁ¤Ë¤·¡¢PICTURE hand ¤ò½ñ¤´¹¤¨¤ë¤³¤È¤Ë¤è¤ê¿Ë¤Î¥Ç¥¶¥¤¥óÊѹ¹¤òÍưפˤǤ¤ë¤è¤¦¤Ë¤·¤Þ¤·¤¿¡£
!¥¢¥Ê¥í¥°»þ·×(²þ)
SET WINDOW -1.2,1.2,-1.2,1.2 !ɽ¼¨Îΰè
SET TEXT JUSTIFY "center","half" !ʸ»úɽ¼¨¤Î½ñ¼°
SET TEXT HEIGHT 1.2/10
SET AREA COLOR 5 ! ¿å¿§
SET POINT STYLE 4 ! ¡£
DRAW disk WITH SCALE(1.1)
FOR i=1 TO 12 !ʸ»úÈ×
LET th=PI/2-2*PI*i/12 !£Ù¼´¤«¤é»þ·×¤Þ¤ï¤ê
PLOT TEXT ,AT COS(th),SIN(th): STR$(i) !±ß¼þ¾å
FOR j=1 TO 4
LET th=PI/2-2*PI*(5*i+j)/60
PLOT POINTS : 0.94*COS(th),0.94*SIN(th)
NEXT j
NEXT i
SET LINE COLOR "RED"
LET t0=INT(TIME)
DRAW clock(t0)
DO
IF TIME-t0>=1 THEN ! Éäι¹¿·¤ÇÉÁ²è
LET t0=INT(TIME)
DRAW clock(t0)
END IF
LOOP
PICTURE clock(t0)
LET h=INT(t0/3600) !¿ôÃͤØ
LET m=INT((t0-3600*h)/60)
LET s=MOD(t0,60)
SET DRAW mode hidden !¤Á¤é¤Ä¤Ëɻߡʳ«»Ï¡Ë
SET AREA COLOR 0 ! Çò
DRAW disk WITH SCALE(0.9) !¿ËÉÁ²èÉôʬ¤Î¤ß¥¯¥ê¥¢
LET th=PI/2-2*PI*(h + m/60)/12 !»þ¿Ë
DRAW hand(3) WITH SCALE(0.6,1)*ROTATE(th)
LET th=PI/2-2*PI*m/60 !ʬ¿Ë
DRAW hand(2) WITH SCALE(0.86,1)*ROTATE(th)
LET th=PI/2-2*PI*s/60 !ÉÿË
PLOT LINES: 0,0; 0.8*COS(th),0.8*SIN(th)
SET DRAW mode explicit !¤Á¤é¤Ä¤ËɻߡʽªÎ»¡Ë
END PICTURE
PICTURE hand(col) !¿ËÉÁ²è
SET AREA COLOR col
PLOT AREA : -0.05,-0.03;1,-0.03;1,0.03;-0.05,0.03
END PICTURE
SET AREA COLOR 5
LET s00=SQR(3)/4
LET ¦Õ=0.001
LET stp=PI/180
DO
IF 2*PI<=ABS(¦Õ) THEN LET stp=-stp !¡¡(¡Ü)º¸²óž (¡Ý)±¦²óž
LET ¦Õ=REMAINDER(¦Õ, 2*PI) +stp
!-----
LET ¦È=¦Õ+SIN(¦Õ*51)*0.1+SIN(¦Õ*49)*0.05 !¡¡¿åÌÌÍɤì..ͤê
!LET ¦È=¦Õ !¡¡¿åÌÌÍɤì..̵¤·
!-----
LET r=0.19985-0.00355*COS(¦È*6) !¡¡±ÕÌÌÊäÀµ¡¢»Ä¸íº¹¡Þ3.85%
LET x00=0
LET y00=0
LET i=1
LET x(i)=x1(¦È)
LET y(i)=y1
IF 0<=x(i) AND x(i)<=1 AND 0<=y(i) AND y(i)<=SQR(3)/2 THEN LET i=i+1
LET x(i)=x2(¦È)
LET y(i)=y2(¦È)
IF 0<=x(i) AND x(i)<=1 AND 0<=y(i) AND y(i)<=SQR(3)/2 THEN LET i=i+1.01
IF i< 3 THEN
LET x(i)=x3(¦È)
LET y(i)=y3(¦È)
IF 2< i THEN
LET x00=1/2
LET y00=SQR(3)/2
ELSE
LET x00=1
LET y00=0
END IF
END IF
LET ss2=ABS((x(1)-x00)*(y(2)-y00)-(y(1)-y00)*(x(2)-x00))
SET DRAW mode hidden
CLEAR
DRAW D4(3) WITH SHIFT(-1/2,-1/SQR(3)/2)*ROTATE(¦Õ-PI/2)
DRAW center WITH SHIFT(-1/2,-1/SQR(3)/2)*ROTATE(-¦Õ-PI/2)*SCALE(-1/8,1/8)
PLOT TEXT,AT 0.13,0.23:"±¦¥¯¥ê¥Ã¥¯¤Ç½ªÎ»"
SET DRAW mode explicit
WAIT DELAY 0.05
MOUSE POLL mx,my,mlb,mrb
LOOP UNTIL mrb>=1
PICTURE center
SET LINE COLOR 2
SET LINE width 2
PLOT LINES:0,0;1,0;1/2,SQR(3)/2;0,0
SET LINE width 1
SET LINE COLOR 1
END PICTURE
!------
PICTURE D4(k)
IF 0< k THEN
DRAW D4(k-1) WITH SCALE(1/2,1/2)*SHIFT(1/4,SQR(3)/4) !¡¡¾å
DRAW D4(k-1) WITH SCALE(1/2,-1/2)*SHIFT(1/4,SQR(3)/4) !¡¡Ãæ
DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(-PI*2/3)*SHIFT(1/4,SQR(3)/4) !º¸
DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(PI*2/3)*SHIFT(1,0) !¡¡±¦
ELSE
DRAW Set01
END IF
END PICTURE
!------ ¼ï¤Î»°³Ñ¿Þ
PICTURE Set01
IF s00< ss2 THEN
IF x00=0 THEN PLOT AREA:x(1),y(1);x(2),y(2);1/2,SQR(3)/2;1,0
IF x00=1 THEN PLOT AREA:x(1),y(1);x(2),y(2);1/2,SQR(3)/2;0,0
IF x00=1/2 THEN PLOT AREA:x(1),y(1);x(2),y(2);1,0;0,0
ELSE
PLOT AREA:x(1),y(1);x(2),y(2);x00,y00
END IF
PLOT LINES:x(1),y(1);x(2),y(2)
PLOT LINES:0,0;1,0;1/2,SQR(3)/2;0,0
END PICTURE
OPTION ARITHMETIC RATIONAL
LET t=fact(52)
LET s=0
FOR i=4 TO 52
LET b=perm(48,52-i) * 4 * fact(i-1) !»Ä¤ë¥«¡¼¥É¡¢£Ë¡¢¤á¤¯¤é¤ì¤Æ¤¤¤¯¥«¡¼¥É¡Ê£³Ëç¤Î£Ë¤ò´Þ¤à¡Ë
PRINT i;"Ëç¡¡³ÎΨ=";b/t
LET s=s+b/t
NEXT i
PRINT "³ÎΨ=";s !¸¡»»
END
¤³¤Î¥×¥í¥°¥é¥à¤Ï¡¤a^n mod k ¤ò·×»»¤·¤Þ¤¹¡£
k¤ÎÃͤ¬8·å¤òĶ¤¨¤ë¤È¤¤ÏÍÍý¿ô¥â¡¼¥É¤Ç¼Â¹Ô¤·¤Æ¤¯¤À¤µ¤¤¡£
100 INPUT k
110 INPUT a,n
120 LET p=1
130 LET b=MOD(a,k)
140 DO UNTIL n=0
150 IF MOD(n,2)=1 THEN LET p=MOD(p*b,k)
160 LET b=MOD(b*b,k)
170 LET n=INT(n/2)
180 LOOP
190 PRINT p
200 END
DECLARE EXTERNAL SUB prime_factor
PUBLIC NUMERIC prn(2000000),pf(100),f
DECLARE FUNCTION modn
LET x=9876543201
LET n=1234567890
LET a=6789012345
LET r=MOD(x,a)
CALL prime_factor(n) ! ÁÇ°ø¿ôʬ²ò
LET k=r
FOR i=1 TO f
LET k=modn(k,pf(i),a)
NEXT i
PRINT k
!
FUNCTION modn(r,n,a) ! mod(r^n,a)
LET kk=r
FOR ii=2 TO n
LET kk=MOD(kk*r,a)
NEXT ii
LET modn=kk
END FUNCTION
END
REM ** ÁÇ°ø¿ôʬ²ò **
EXTERNAL SUB prime_factor(n)
DECLARE EXTERNAL SUB prime
LET f=0 ! ÁÇ°ø¿ô¤Î¸Ä¿ô
LET q=n ! q¤Ï¡¢¾¦
LET m=1 ! ¸¡¾ÚÍÑÊÑ¿ô
FOR i=1 TO 10
READ prn(i)
NEXT i
DATA 2,3,5,7,11,13,17,19,23,29
LET i=1
DO WHILE MOD(q,prn(i))=0 ! °ø¿ôȽÄê¥ë¡¼¥Á¥ó
LET f=f+1
LET pf(f)=prn(i) ! pf(f)¤Ïn¤ÎfÈÖÌܤÎÁÇ°ø¿ô
LET q=q/prn(i)
LET m=m*prn(i)
LOOP
LET i=2
DO WHILE prn(i)<=SQR(q)
DO WHILE MOD(q,prn(i))=0 ! °ø¿ôȽÄê¥ë¡¼¥Á¥ó
LET f=f+1
LET pf(f)=prn(i) ! pf(f)¤Ïn¤ÎfÈÖÌܤÎÁÇ°ø¿ô
LET q=q/prn(i)
LET m=m*prn(i)
LOOP
IF q=1 THEN EXIT DO
LET i=i+1
IF i>10 THEN CALL prime(i) ! iÈÖÌܤÎÁÇ¿ô
LOOP
IF q<>1 THEN
LET f=f+1
LET pf(f)=q
LET m=m*q
END IF
IF m<>n THEN PRINT "error !!"
END SUB
!
REM ** ÁÇ¿ôÎóÀ¸À®(kÈÖÌܤÎÁÇ¿ô) **
EXTERNAL SUB prime(k)
LET m30=MOD(prn(k-1),30)
IF m30=1 OR m30=23 THEN LET a=prn(k-1)+6 ELSE LET a=prn(k-1)-2*MOD(m30,3)+6
DO
LET sqra=SQR(a)
FOR j=4 TO k-1
IF MOD(a,prn(j))=0 THEN EXIT FOR
IF prn(j)>=sqra THEN
LET prn(k)=a
EXIT SUB
END IF
NEXT j
LET m30=MOD(a,30)
IF m30=1 OR m30=23 THEN LET a=a+6 ELSE LET a=a-2*MOD(m30,3)+6
LOOP
END SUB
m²ó¥·¥ã¥Ã¥Õ¥ë¤ò·«¤êÊÖ¤¹¤È
f(f(f(¡Ä(f(k)))))=2*(2*(2*¡Ä(2*k mod n+1) mod n+1) mod n+1) mod n+1=2^m*k mod n+1
°ìÍ÷ɽ¤ò¤Ä¤¯¤ë¥×¥í¥°¥é¥à
!¥ê¥Õ¥ë¥·¥ã¥Ã¥Õ¥ë
!nËç¤Î¥«¡¼¥É¤ò1,2,3,¡Ä,n-1,n¤Ëʤ٤롣
!£±²ó¤Î¥·¥ã¥Ã¥Õ¥ë¤Ç¥«¡¼¥Ék¤¬¸½¤ì¤ë°ÌÃÖ¤òf(k)¤Èɽ¤¹¡£¡Ê¥«¡¼¥Ék¤Ïf(k)ÈÖÌܤˤ¢¤ë¡Ë
DEF f(k)=MOD(2*k,n+1)
FOR n=2 TO 100 STEP 2 !¶ö¿ô
PRINT USING "### Ë硧":n;
LET x=1 !¥«¡¼¥Éx¤ËÃåÌÜ
LET iter=1000
FOR m=1 TO iter !m²ó¤Î¥·¥ã¥Ã¥Õ¥ë¡¡¢¨
LET x=f(x) !2^m*k (mod n+1)
!!!PRINT m;x
IF x=n THEN PRINT USING "### ²óÌܤǵս硢":m; !µÕ½ç
IF x=1 THEN EXIT FOR !¤â¤È¤ËÌá¤ë
NEXT m
IF m>iter THEN
PRINT USING "### ²ó¤Ç¤Ï¸µ¤ËÌá¤ê¤Þ¤»¤ó¡£":m
ELSE
PRINT USING "### ²óÌܤ˸µ¤ËÌá¤ë":m
END IF
NEXT n
END
FOR n=2 TO 100 STEP 2 !¶ö¿ô
PRINT USING "### Ë硧":n;
LET iter=1000
FOR m=1 TO iter
LET x=modinv(2^m,n+1) !£±ËçÌܤΥ«¡¼¥É¤Î¸µ¤Î°ÌÃÖ¤òÆÀ¤ë
IF x=n THEN PRINT USING "### ²óÌܤǵս硢":m; !µÕ½ç
IF x=1 THEN EXIT FOR !¤â¤È¤ËÌá¤ë
NEXT m
IF m>iter THEN
PRINT USING "### ²ó¤Ç¤Ï¸µ¤ËÌá¤ê¤Þ¤»¤ó¡£":m
ELSE
PRINT USING "### ²óÌܤ˸µ¤ËÌá¤ë":m
END IF
NEXT n
END
EXTERNAL FUNCTION modpow(a,b,n) !a^b¢áx mod n ¤Îx¤òÊÖ¤¹
LET S=1
DO WHILE b>0
IF MOD(b,2)=1 THEN LET S=MOD(S*a,n) !¥Ó¥Ã¥È¤¬£±¤Ê¤é·×»»¤¹¤ë
LET b=INT(b/2) !¤Ù¤¾èb¤ò£²¿ÊŸ³«¤¹¤ë
LET a=MOD(a*a,n)
LOOP
LET modpow=S
END FUNCTION
!»³¤ò»È¤Ã¤¿¥·¥ã¥Ã¥Õ¥ë
LET p=3 !»³¤Î¿ô
FOR n=p TO 100 STEP p !p¤ÎÇÜ¿ô
PRINT USING "### Ë硧":n;
LET iter=1000
FOR m=1 TO iter
!!!LET x=modinv((n*p)^m,n+1) !£±ËçÌܤΥ«¡¼¥É¤Î¸µ¤Î°ÌÃÖ¡Ê¥«¡¼¥ÉÈÖ¹æ¡Ë¤òÆÀ¤ë
LET x=modpow(n*p,m,n+1) !£±È֤Υ«¡¼¥É¤Î°ÌÃÖ¤òÆÀ¤ë
IF x=n THEN PRINT USING "### ²óÌܤǵս硢":m; !µÕ½ç
IF x=1 THEN EXIT FOR !¤â¤È¤ËÌá¤ë
NEXT m
IF m>iter THEN
PRINT USING "##### ²ó¤Ç¤Ï¸µ¤ËÌá¤ê¤Þ¤»¤ó¡£":m
ELSE
PRINT USING "### ²óÌܤ˸µ¤ËÌá¤ë":m
END IF
NEXT n
END
!¡¡»þ·×¡¢»þ·×¡¢»þ·×
!-------------------
LET N=2
LET NN=2^N
SET TEXT font "Century",11
SET TEXT JUSTIFY "center","half"
SET TEXT BACKGROUND "OPAQUE"
SET WINDOW -250/NN,250/NN,250/NN,-250/NN
LET ¦Õ=0
LET stp=-PI/180*6
DO
LET t=INT(TIME)
IF t0<>t THEN
LET t0=t
IF 2*PI<=ABS(¦Õ) THEN LET stp=-stp
LET ¦Õ=REMAINDER(¦Õ, 2*PI) +stp
!-----
SET DRAW mode hidden
CLEAR
DRAW D4(N) WITH SHIFT(-300/2,-300/2/SQR(3))*ROTATE(¦Õ*(-1)^N)*SCALE(1,(-1)^N)
DRAW center WITH SHIFT(-300/2/NN,-300/2/NN/SQR(3))*ROTATE(¦Õ)
PLOT TEXT,AT 180/NN,-240/NN:"Right Click to Stop"
SET DRAW mode explicit
ELSE
WAIT DELAY 0.05 !¡¡¾ÊÅÅÎϸú²Ì
END IF
MOUSE POLL mx,my,mlb,mrb
LOOP UNTIL mrb>=1 !¡¡±¦¥¯¥ê¥Ã¥¯¤ÇÄä»ß
PICTURE center
SET LINE COLOR 2
SET LINE width 2
PLOT LINES:0,0;300/NN,0;300/2/NN,300/2/NN*SQR(3);0,0
SET LINE width 1
SET LINE COLOR 1
END PICTURE
!------
PICTURE D4(k)
IF 0< k THEN
DRAW D4(k-1) WITH SCALE(1/2,1/2)*SHIFT(300/4,SQR(3)*300/4) !¡¡Æ⦤ξå
DRAW D4(k-1) WITH SCALE(1/2,-1/2)*SHIFT(300/4,SQR(3)*300/4) !¡¡Æ⦤ÎÃæ
DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(-PI*2/3)*SHIFT(300/4,SQR(3)*300/4) !Æ⦤κ¸
DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(PI*2/3)*SHIFT(300,0) !¡¡Æ⦤α¦
ELSE
DRAW »þ·×¿Þ WITH ROTATE(-¦Õ)*SHIFT(300/2,300/2/SQR(3))
PLOT LINES:0,0;300,0;300/2,SQR(3)*300/2;0,0 !¡¡³°Â¦¤Î´ð½à»°³Ñ·Á¡ÊľÀܤÎÉÁ²è¤Ï̵¤·¡£)
END IF
END PICTURE
!------
PICTURE »þ·×¿Þ
SET AREA COLOR 1
FOR i=1 TO 60
LET a=PI/30*(i-15)
IF MOD(i,5)=0 THEN
PLOT label,AT 60*COS(a)+1, 60*SIN(a) :STR$(i/5) !¿ô»ú
DRAW disk WITH SCALE(1)*SHIFT(72*COS(a),72*SIN(a)) !£µÊ¬ÌÜÀ¹¤ê
ELSE
DRAW disk WITH SCALE(.5)*SHIFT(72*COS(a),72*SIN(a)) !£±Ê¬ÌÜÀ¹¤ê
END IF
NEXT i
!---¡¡00:00 ¤«¤é£ôÉà ¤Î¿Ë²óž Gear
DRAW hand(1) WITH SCALE(2.5, 0.75)*ROTATE(t*PI/21600) !¡¡»þ¿Ë
DRAW hand(1) WITH ROTATE(t*PI/1800) !¡¡Ê¬¿Ë
DRAW hand(1) WITH SCALE(0, 1.1)*ROTATE(t*PI/30) !¡¡ÉÿË
!---¡¡Ãæ¿´¤Î¾þ¤ê
DRAW disk WITH SHIFT(0,0)*SCALE(4)
END PICTURE
PICTURE hand(c) !¡¡£³¿Ë¶¦ÍÑ
SET AREA COLOR c
PLOT AREA: -1,15; 1,15; 1,-60; -1,-60
END PICTURE
MAT READ px
DATA 0.20, 0.40, 0.60, 0.80, 0.70, 0.60, 0.50, 0.40, 0.30, 0.20, 0.40
MAT READ py
DATA 0.11, 0.11, 0.11, 0.11, 0.29, 0.47, 0.65, 0.47, 0.29, 0.11, 0.11
!----------
FOR N=0 TO 4
FOR s=9 TO 1 STEP -1
SET DRAW mode hidden
CLEAR
SET WINDOW -0.4,1.6, -1.1,0.9
PLOT TEXT,AT 0.6,0.8:"¥ß¥é¡¼½Ì¾®£´Ê¬´ô"
PLOT TEXT,AT 0.8,0.7, USING "N= %%":N
DRAW D4(N)
SET WINDOW -1.0,1.0, -0.05,1.95
PLOT TEXT,AT 0.6,0.8:"Ãæ¤òÈ´¤¤¤¿¤â¤Î"
PLOT TEXT,AT 0.8,0.7, USING "N= %%":N
DRAW D42(N)
SET WINDOW 0.0,4.0, -0.1,3.9
PLOT TEXT,AT 0.1,1.8:"¥·¥ë¥Ô¥ó¥¹¥¡¼¤Î¥¬¥¹¥±¥Ã¥È"
PLOT TEXT,AT 1.2,1.6, USING "N= %%":N
DRAW D3(N)
SET DRAW mode explicit
WAIT DELAY 0.2
NEXT s
NEXT N
!------ ¥ß¥é¡¼½Ì¾®£´Ê¬´ô
PICTURE D4(k)
IF 0<k THEN
DRAW D4(k-1) WITH SCALE(1/2,1/2)*SHIFT(1/4,SQR(3)/4) !¡¡¾å
DRAW D4(k-1) WITH SCALE(1/2,-1/2)*SHIFT(1/4,SQR(3)/4) !¡¡Ãæ
DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(-PI*2/3)*SHIFT(1/4,SQR(3)/4) !¡¡º¸
DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(PI*2/3)*SHIFT(1,0) !¡¡±¦
ELSE
DRAW Set01
END IF
END PICTURE
!------ ¥ß¥é¡¼½Ì¾®£´Ê¬´ô¡ÊÃæ¡Ë¤ò³°¤¹¤È¡¢¥·¥ë¥Ô¥ó¥¹¥¡¼¤Î¥¬¥¹¥±¥Ã¥È¤â¤É¤¤Ë¤Ê¤ë¡£
PICTURE D42(k)
IF 0<k THEN
DRAW D42(k-1) WITH SCALE(1/2,1/2)*SHIFT(1/4,SQR(3)/4) !¡¡¾å
! ¤³¤ì¤ò³°¤¹¡¡DRAW D42(k-1) WITH SCALE(1/2,-1/2)*SHIFT(1/4,SQR(3)/4) !¡¡Ãæ
DRAW D42(k-1) WITH SCALE(1/2,1/2)*ROTATE(-PI*2/3)*SHIFT(1/4,SQR(3)/4) !¡¡º¸
DRAW D42(k-1) WITH SCALE(1/2,1/2)*ROTATE(PI*2/3)*SHIFT(1,0) !¡¡±¦
ELSE
DRAW Set01
END IF
END PICTURE
!------ ¥·¥ë¥Ô¥ó¥¹¥¡¼¤Î¥¬¥¹¥±¥Ã¥È
PICTURE D3(k)
IF 0<k THEN
!---¥ê¥ó¥¯¡¦BASIC¤ÇÉÁ¤¯¼«¸ÊÁê»÷¿Þ·Á¤«¤éÇÒ¼Ú
DRAW D3(k-1) WITH SCALE(1/2)
DRAW D3(k-1) WITH SHIFT(-2,0)*SCALE(1/2)*SHIFT(2,0)
DRAW D3(k-1) WITH SHIFT(-1,-SQR(3))*SCALE(1/2)*SHIFT(1,SQR(3))
ELSE
DRAW Set01
END IF
END PICTURE
!------ ¿Æ½¸¹ç¤Î»°³Ñ¿Þ£±Ëç
PICTURE Set01
PLOT LINES: 0,0; 1,0 ;0.5,SQR(3)/2 ;0,0
SET AREA COLOR 2
DRAW disk WITH SCALE(0.1)*SHIFT(px(s),py(s)) ! ¾þ¤ê£±
SET AREA COLOR 3
DRAW disk WITH SCALE(0.1)*SHIFT(px(s+1),py(s+1)) ! ¾þ¤ê£²
SET AREA COLOR 4
DRAW disk WITH SCALE(0.1)*SHIFT(px(s+2),py(s+2)) ! ¾þ¤ê£³
END PICTURE
LET maxim=13 !¡¡ºÇÂçËç¿ô 2~1000
DIM buf(1000), bufw(1000)
SUB in_riffle_shuffle !¥¤¥ó¤Î¥ê¥Õ¥ë¡£´ñ¿ôËç¤Ï¡¢¸åȾ¤ò£±Ë翤á
MAT bufw=buf
FOR i=1 TO n
LET buf(i)= bufw(CEIL(i/2)+MOD(i,2)*INT(n/2)) !1234¢ª3142, 12345¢ª31425
NEXT i
END SUB
SUB out_riffle_shuffle !¥¢¥¦¥È¤Î¥ê¥Õ¥ë¡£´ñ¿ôËç¤Ï¡¢Á°È¾¤ò£±Ë翤á
MAT bufw=buf
FOR i=1 TO n
LET buf(i)= bufw(CEIL(i/2)+MOD(i+1,2)*CEIL(n/2)) !1234¢ª1324, 12345¢ª13243
NEXT i
END SUB
FOR n=2 TO maxim !STEP 2 !¡¡Step ¤ò³°¤»¤Ð´ñ¿ô¤â·×»»¡£
!-----
MAT buf=ZER(n) !¡¡ÇÛÎó¥µ¥¤¥ºÄ´À°¡¢ÄɲÃ
!-----
FOR i=1 TO n
LET buf(i)= i
NEXT i
LET cc=0
LET c=0
!-----
IF maxim<15 THEN MAT PRINT USING REPEAT$(" ###",n) :buf !¡¡É½¼¨¡¢ÄɲÃ
!-----
DO
LET c=c+1
CALL in_riffle_shuffle ! 1234¢ª3142, 12345¢ª31425
!CALL out_riffle_shuffle ! 1234¢ª1324, 12345¢ª13243
!-----
IF maxim<15 THEN MAT PRINT USING REPEAT$(" ###",n) :buf !¡¡É½¼¨¡¢ÄɲÃ
!-----
FOR i=1 TO n
IF buf(i)<> n+1-i THEN EXIT FOR
NEXT i
IF i>n AND cc=0 THEN LET cc=c
FOR i=1 TO n
IF buf(i)<>i THEN EXIT FOR
NEXT i
LOOP UNTIL i>n
PRINT USING "Ëç¿ô=###¡¡Æ±½ç=###¡¡µÕ½ç=###¡ÊÉü¸µ²ó¿ô¡Ë": n, c, cc
IF maxim<15 THEN PRINT !¡¡É½¼¨¡¢ÄɲÃ
NEXT n
!¿¿ÍýÃÍɽ
LET a=3 !0011¤Î¥Ñ¥¿¡¼¥ó
LET b=5 !0101¤Î¥Ñ¥¿¡¼¥ó
PRINT " b NOT" !ÈÝÄê
FOR i=0 TO 1
PRINT bit(i,b); 1-bit(i,b) !b'=1-b
NEXT i
PRINT " a b IMP" !ÏÀÍýÊñ´Þ
FOR i=0 TO 3
PRINT bit(i,a); bit(i,b); bit(i,bitor(bitreverse(i,a),b)) !a' or b
NEXT i
PRINT " a b EQV" !ƱÃÍ
FOR i=0 TO 3
PRINT bit(i,a); bit(i,b); 1-bit(i,bitxor(a,b)) !(a xor b)'
NEXT i
!£²¤ÎÊä¿ô¡§ÄêµÁ¤è¤ê
LET n=16 !£î¥Ó¥Ã¥ÈÉä¹æÉÕÀ°¿ô -2^(n-1)¡Á2^(n-1)-1
LET m=2^n
LET a=3
LET aa=m-a !a+a'=m
FOR i=N-1 TO 0 STEP -1 !¾å¤Î°Ì¤«¤é
PRINT bit(i,aa);
NEXT i
PRINT
!£²¤ÎÊä¿ô¡§È¿Å¾¤·¤Æ£±¤ò¤¿¤¹
LET a=3
FOR i=N-1 TO 0 STEP -1 !¾å¤Î°Ì¤«¤é
LET a=bitreverse(i,a)
NEXT i
LET a=a+1
PRINT a !£î¥Ó¥Ã¥ÈÉä¹æ¤Ê¤·À°¿ô 0¡Á2^n-1
!£²¤ÎÊä¿ô¡§È¿Å¾¤·¤Æ£±¤ò¤¿¤¹¡¡¢¨Ê̲ò
LET a=3
FOR i=0 TO N-1 !²¼¤Î°Ì¤«¤é
IF bit(i,a)=1 THEN EXIT FOR !£±¤¬¸«¤Ä¤«¤ë¤Þ¤Ç
LET a=bitreset(i,a) !£°¤Ë¤¹¤ë
NEXT i
FOR k=i+1 TO N-1 !³¤
LET a=bitreverse(k,a) !£°¤ò£±¤Ë¤¹¤ë
NEXT k
PRINT a
!²Ã»» a+b
LET a=123
LET b=45
DO WHILE bitand(a,b)>0
LET t=bitxor(a,b)
LET b=sft(bitand(a,b),1)
LET a=t
LOOP
PRINT bitxor(a,b)
END
!¥Ó¥Ã¥È±é»»´ØÏ¢¡¡¢¨UBASIC¤è¤ê
EXTERNAL FUNCTION bit(n,x) !nÈÖÌܤΥӥåÈÃÍ¡¡¢¨n,x¤ÏÀ°¿ô
IF n<>INT(n) OR x<>INT(x) THEN !À°¿ô°Ê³°¤Ê¤é
PRINT "¥Ñ¥é¥á¡¼¥¿¤¬ÉÔŬÅö¤Ç¤¹¡£"
STOP
ELSE
LET bit=MOD(INT(x/2^n),2)
END IF
END FUNCTION
EXTERNAL FUNCTION bitset(n,x) !nÈÖÌܤΥӥåȤò£±¤Ë¤¹¤ë¡¡¢¨n,x¤ÏÈóÉéÀ°¿ô
IF n<0 OR n<>INT(n) OR x<0 OR x<>INT(x) THEN !ÈóÉéÀ°¿ô°Ê³°¤Ê¤é
PRINT "¥Ñ¥é¥á¡¼¥¿¤¬ÉÔŬÅö¤Ç¤¹¡£"
STOP
ELSE
LET d=2^n !n·å
LET bitset=(INT(x/d/2)*2+1)*d+MOD(x,d) !Â礤¤·å¡Ü£±¡Ü¾®¤µ¤¤·å
END IF
END FUNCTION
EXTERNAL FUNCTION bitreset(n,x) !nÈÖÌܤΥӥåȤò£°¤Ë¤¹¤ë¡¡¢¨n,x¤ÏÈóÉéÀ°¿ô
IF n<0 OR n<>INT(n) OR x<0 OR x<>INT(x) THEN !ÈóÉéÀ°¿ô°Ê³°¤Ê¤é
PRINT "¥Ñ¥é¥á¡¼¥¿¤¬ÉÔŬÅö¤Ç¤¹¡£"
STOP
ELSE
LET d=2^n !n·å
LET bitreset=INT(x/d/2)*2*d+MOD(x,d) !Â礤¤·å¡Ü£±¡Ü¾®¤µ¤¤·å
END IF
END FUNCTION
EXTERNAL FUNCTION bitreverse(n,x) !nÈÖÌܤΥӥåȤòȿž¤¹¤ë¡¡¢¨n,x¤ÏÈóÉéÀ°¿ô
IF n<0 OR n<>INT(n) OR x<0 OR x<>INT(x) THEN !ÈóÉéÀ°¿ô°Ê³°¤Ê¤é
PRINT "¥Ñ¥é¥á¡¼¥¿¤¬ÉÔŬÅö¤Ç¤¹¡£"
STOP
ELSE
LET d=2^n !n·å
LET a=INT(x/d)
LET bitreverse=(INT(a/2)*4-a+1)*d+MOD(x,d) !Â礤¤·å¡ÜNOT¡Ü¾®¤µ¤¤·å
END IF
END FUNCTION
EXTERNAL FUNCTION bitand(a,b) !¥Ó¥Ã¥È¤´¤È¤ÎÏÀÍýÀÑ¡¡¢¨a,b¤ÏÈóÉéÀ°¿ô
IF a<0 OR a<>INT(a) OR b<0 OR b<>INT(b) THEN !ÈóÉéÀ°¿ô°Ê³°¤Ê¤é
PRINT "¥Ñ¥é¥á¡¼¥¿¤¬ÉÔŬÅö¤Ç¤¹¡£"
STOP
ELSE
LET c=0 !ÃÍ
LET d=1
DO UNTIL a=0 OR b=0 !ºÇ²¼°Ì¤Î·å¤«¤é¡¢·å¿ô¤¬¾®¤µ¤¤Êý¤Þ¤Ç
LET aa=INT(a/2)
LET bb=INT(b/2)
LET c=c + MIN((a-aa*2),(b-bb*2)) * d !and(x,y)=MIN(x,y)
LET a=aa !¼¡¤Ø
LET b=bb
LET d=d*2
LOOP
LET bitand=c
END IF
END FUNCTION
EXTERNAL FUNCTION bitor(a,b) !¥Ó¥Ã¥È¤´¤È¤ÎÏÀÍýÏ¡¡¢¨a,b¤ÏÈóÉéÀ°¿ô
IF a<0 OR a<>INT(a) OR b<0 OR b<>INT(b) THEN !ÈóÉéÀ°¿ô°Ê³°¤Ê¤é
PRINT "¥Ñ¥é¥á¡¼¥¿¤¬ÉÔŬÅö¤Ç¤¹¡£"
STOP
ELSE
LET c=0
LET d=1
DO UNTIL a=0 AND b=0 !·å¿ô¤¬Â礤¤Êý
LET aa=INT(a/2)
LET bb=INT(b/2)
LET c=c+MAX((a-aa*2),(b-bb*2)) * d !or(x,y)=MAX(x,y)
LET a=aa !¼¡¤Ø
LET b=bb
LET d=d*2
LOOP
LET bitor=c
END IF
END FUNCTION
EXTERNAL FUNCTION bitxor(a,b) !¥Ó¥Ã¥È¤´¤È¤ÎÇÓ¾ŪÏÀÍýÏ¡¡¢¨a,b¤ÏÈóÉéÀ°¿ô
IF a<0 OR a<>INT(a) OR b<0 OR b<>INT(b) THEN !ÈóÉéÀ°¿ô°Ê³°¤Ê¤é
PRINT "¥Ñ¥é¥á¡¼¥¿¤¬ÉÔŬÅö¤Ç¤¹¡£"
STOP
ELSE
LET c=0
LET d=1
DO UNTIL a=0 AND b=0 !·å¿ô¤¬Â礤¤Êý
LET aa=INT(a/2)
LET bb=INT(b/2)
LET c=c + MOD((a-aa*2)+(b-bb*2),2) * d !xor(x,y)=MOD(x+y,2)
LET a=aa !¼¡¤Ø
LET b=bb
LET d=d*2
LOOP
LET bitxor=c
END IF
END FUNCTION
EXTERNAL FUNCTION bitcount(x) !£±¤Ç¤¢¤ë¥Ó¥Ã¥È¤Î¸Ä¿ô¡¡¢¨x¤ÏÈóÉéÀ°¿ô
IF x<0 OR x<>INT(x) THEN !ÈóÉéÀ°¿ô°Ê³°¤Ê¤é
PRINT "¥Ñ¥é¥á¡¼¥¿¤¬ÉÔŬÅö¤Ç¤¹¡£"
STOP
ELSE
LET c=0 !ÃÍ
DO UNTIL x=0 !ºÇ²¼°Ì¤Î·å¤«¤é
LET xx=INT(x/2) !¾¦
LET c=c + (x-xx*2) !;¤ê
LET x=xx !¼¡¤Ø
LOOP
LET bitcount=c
END IF
END FUNCTION
EXTERNAL FUNCTION sft(x,n) !n¥Ó¥Ã¥È¤Î¥·¥Õ¥È¤¹¤ë¡¡¢¨n¤ÏÀ°¿ô
IF n<>INT(n) THEN !À°¿ô°Ê³°¤Ê¤é
PRINT "¥Ñ¥é¥á¡¼¥¿¤¬ÉÔŬÅö¤Ç¤¹¡£"
STOP
ELSE
IF n<0 THEN LET d=1/2 ELSE LET d=2
FOR i=1 TO ABS(n)
LET x=x*d
NEXT i
LET sft=x
END IF
END FUNCTION
OPTION BASE 0
PUBLIC NUMERIC MAXLEVEL
LET MAXLEVEL=10 !'¼¡¿ô
DIM X(1),Y(MAXLEVEL),L(MAXLEVEL)
LET DISPMODE=0 !' 0 or else
LET INTEGRAL=1 !' INTEGRAL >= 1
LET SWITCH=0 !' 0...ÊĤ¸¤¿¸ø¼° else...³«¤¤¤¿¸ø¼°
IF DISPMODE<>0 THEN
IF INTEGRAL > 1 THEN
PRINT "DIM A(";STR$(INTEGRAL);"),B(";STR$(INTEGRAL);"),N(";STR$(INTEGRAL);")"
PRINT "FOR I=1 TO";INTEGRAL
LET A$="(" & CHR$(34) & "
& STR$(I) & " & CHR$(34) & ")=" & CHR$(34) & ":"
LET B$="(I)"
ELSE
LET A$="=" & CHR$(34) & ":"
LET B$=""
END IF
LET C$="! INPUT PROMPT " & CHR$(34)
PRINT C$;"²¼¸Â ";A$;"A";B$
PRINT C$;"¾å¸Â ";A$;"B";B$
PRINT C$;"ʬ³ä¿ô";A$;"N";B$
PRINT "READ A";B$;",B";B$;",N";B$
IF INTEGRAL > 1 THEN PRINT "NEXT"
FOR I=1 TO INTEGRAL
PRINT "DATA 0,1,10"
NEXT I
FOR I=2 TO MAXLEVEL
PRINT "PRINT INTEGRAL";STR$(I);"(";
IF INTEGRAL=1 THEN
PRINT "A,B,N)"
ELSE
FOR J=1 TO INTEGRAL
PRINT "A(";STR$(J);"),B(";STR$(J);"),";
NEXT J
FOR J=1 TO INTEGRAL
PRINT "N(";STR$(J);")";
IF J < INTEGRAL THEN PRINT ",";
NEXT J
PRINT ")"
END IF
NEXT I
PRINT "END"
PRINT
PRINT "EXTERNAL FUNCTION FUNC(";
FOR I=1 TO INTEGRAL
PRINT "X";STR$(I);
IF I < INTEGRAL THEN PRINT ",";
NEXT I
PRINT ")"
PRINT "LET S=1";
FOR I=1 TO INTEGRAL
PRINT "-X";STR$(I);"*X";STR$(I);
NEXT I
PRINT
PRINT "IF S > 0 THEN"
PRINT "LET FUNC=SQR(S)"
PRINT "ELSE"
PRINT "LET FUNC=0"
PRINT "END IF"
PRINT "END FUNCTION"
PRINT
END IF
LET X(1)=1
FOR N=1 TO MAXLEVEL-1
FOR I=0 TO N
CALL CLR(Y)
LET P=1
LET Y(0)=1
FOR J=0 TO N
IF I<>J THEN
LET X(0)=-J
CALL MUL(Y,X)
LET P=P*(I-J)
END IF
NEXT J
CALL INTEGRAL(Y)
IF SWITCH=0 THEN
LET L(I)=HORNER(Y,N)/P
ELSE
LET L(I)=(HORNER(Y,N+1)-HORNER(Y,-1))/P
END IF
NEXT I
IF DISPMODE<>0 THEN
PRINT "EXTERNAL FUNCTION INTEGRAL";STR$(N+1);"(";
IF INTEGRAL > 1 THEN
FOR J=1 TO INTEGRAL
PRINT "A";STR$(J);",B";STR$(J);",";
NEXT J
FOR J=1 TO INTEGRAL
PRINT "N";STR$(J);
IF J < INTEGRAL THEN PRINT ",";
NEXT J
ELSE
PRINT "A,B,N";
END IF
PRINT ")"
IF SWITCH=0 THEN LET A$=STR$(N) ELSE LET A$=STR$(N+2)
IF INTEGRAL=1 THEN
PRINT "LET H=(B-A)/N/";A$
PRINT "LET S=0"
PRINT "FOR K=0 TO N-1"
PRINT "LET S=S";
FOR I=0 TO N
IF SWITCH=0 THEN LET B$=STR$(I) ELSE LET B$=STR$(I+1)
IF L(I) < 0 THEN PRINT "-"; ELSE PRINT "+";
PRINT STR$(ABS(L(I)));"*H*FUNC(A+H*(";A$;"*K+";B$;"))";
NEXT I
PRINT
PRINT "NEXT"
ELSE
IF SWITCH=0 THEN
PRINT "DIM R(0 TO ";STR$(N);")"
ELSE
PRINT "DIM R(";STR$(N+1);")"
END IF
FOR I=0 TO N
IF SWITCH=0 THEN LET B$=STR$(I) ELSE LET B$=STR$(I+1)
PRINT "R(";B$;")=";
IF L(I) < 0 THEN PRINT "-";
PRINT STR$(ABS(L(I)))
NEXT I
FOR J=1 TO INTEGRAL
PRINT
"LET H";STR$(J);"=(B";STR$(J);"-A";STR$(J);")/N";STR$(J);"/";A$
NEXT J
PRINT "LET S=0"
FOR J=INTEGRAL TO 1 STEP -1
PRINT "FOR K";STR$(J);"=0 TO N";STR$(J);"-1"
NEXT J
FOR J=1 TO INTEGRAL
IF SWITCH=0 THEN
PRINT "FOR J";STR$(J);"=0 TO";N
ELSE
PRINT "FOR J";STR$(J);"=1 TO";N+1
END IF
NEXT J
PRINT "LET S=S+";
FOR J=1 TO INTEGRAL
PRINT "R(J";STR$(J);")*";
NEXT J
FOR I=1 TO INTEGRAL
PRINT "H";STR$(I);"*";
NEXT I
PRINT "FUNC(";
FOR I=1 TO INTEGRAL
PRINT
"A";STR$(I);"+H";STR$(I);"*(";A$;"*K";STR$(I);"+J";STR$(I);")";
IF I < INTEGRAL THEN PRINT ",";
NEXT I
PRINT ")"
FOR I=1 TO INTEGRAL*2
PRINT "NEXT"
NEXT I
END IF
PRINT "LET INTEGRAL";STR$(N+1);"=S"
PRINT "END FUNCTION"
ELSE
PRINT "¢é(x";STR$(N);",x0)f(x)dx=";
FOR I=0 TO N
IF L(I) < 0 THEN
PRINT "-";
ELSE
IF I > 0 THEN PRINT "+";
END IF
PRINT STR$(ABS(L(I)));"*h*f(x";STR$(I);")";
NEXT I
PRINT
END IF
PRINT
NEXT N
END
EXTERNAL SUB MUL(A(),B())
OPTION BASE 0
DIM C(MAXLEVEL)
FOR I=0 TO MAXLEVEL-1
FOR J=0 TO 1
LET C(I+J)=C(I+J)+A(I)*B(J)
NEXT J
NEXT I
CALL COPY(A,C)
END SUB
EXTERNAL FUNCTION HORNER(A(),XX)
FOR N=MAXLEVEL TO 0 STEP -1
IF A(N)<>0 THEN EXIT FOR
NEXT N
LET Y=A(N)
FOR I=N-1 TO 0 STEP -1
LET Y=Y*XX+A(I)
NEXT I
LET HORNER=Y
END FUNCTION
EXTERNAL SUB COPY(X(),Y())
FOR I=0 TO MAXLEVEL
LET X(I)=Y(I)
NEXT I
END SUB
EXTERNAL SUB CLR(X())
FOR I=0 TO MAXLEVEL
LET X(I)=0
NEXT I
END SUB
EXTERNAL SUB INTEGRAL(A())
OPTION BASE 0
DIM B(MAXLEVEL)
FOR I=MAXLEVEL-1 TO 0 STEP -1
LET B(I+1)=A(I)/(I+1)
NEXT I
CALL COPY(A,B)
END SUB
OPTION BASE 0
OPTION ARITHMETIC DECIMAL_HIGH
PUBLIC NUMERIC MAXLEVEL,EPS
LET MAXLEVEL=10 !'¼¡¿ô
DIM X(MAXLEVEL),W(MAXLEVEL)
LET KETA=16 !'µá¤á¤ë·å¿ô
LET EPS=10^(-KETA)
LET DISPMODE=0 !' 0 or else
LET INTEGRAL=1 !' INTEGRAL >= 1
IF DISPMODE<>0 THEN
CALL LEGENDREPARA(MAXLEVEL,X,W)
PRINT "DIM X(";STR$(MAXLEVEL);"),W(";STR$(MAXLEVEL);")"
FOR I=1 TO INTEGRAL
PRINT "! INPUT PROMPT ";CHR$(34);"²¼¸Â ";STR$(I);"=";CHR$(34);":A";STR$(I)
PRINT "! INPUT PROMPT ";CHR$(34);"¾å¸Â ";STR$(I);"=";CHR$(34);":B";STR$(I)
NEXT I
FOR I=1 TO INTEGRAL
PRINT "LET A";STR$(I);"=0"
PRINT "LET B";STR$(I);"=1"
NEXT I
FOR J=1 TO INTEGRAL
PRINT "LET U";STR$(J);"=(B";STR$(J);"+A";STR$(J);")/2"
PRINT "LET V";STR$(J);"=(B";STR$(J);"-A";STR$(J);")/2"
NEXT J
PRINT "FOR I=1 TO";MAXLEVEL
PRINT "READ X(I),W(I)"
PRINT "NEXT"
PRINT "LET S=0"
FOR J=1 TO INTEGRAL
PRINT "FOR K";STR$(J);"=1 TO";MAXLEVEL
NEXT J
PRINT "LET S=S+";
FOR J=1 TO INTEGRAL
PRINT "W(K";STR$(J);")*";
NEXT J
PRINT "FUNC(";
FOR I=1 TO INTEGRAL
PRINT "U";STR$(I);"+V";STR$(I);"*X(K";STR$(I);")";
IF I < INTEGRAL THEN PRINT ",";
NEXT I
PRINT ")";
FOR J=1 TO INTEGRAL
PRINT "*V";STR$(J);
NEXT J
PRINT
FOR J=1 TO INTEGRAL
PRINT "NEXT"
NEXT J
PRINT "PRINT S"
FOR I=1 TO MAXLEVEL
PRINT "DATA ";
PRINT USING "#." & REPEAT$("#",KETA):X(I);
PRINT ",";
PRINT USING "#." & REPEAT$("#",KETA) & "^^^^":W(I)
NEXT I
PRINT "END"
PRINT
PRINT "EXTERNAL FUNCTION FUNC(";
FOR I=1 TO INTEGRAL
PRINT "X";STR$(I);
IF I < INTEGRAL THEN PRINT ",";
NEXT I
PRINT ")"
PRINT "LET S=1";
FOR I=1 TO INTEGRAL
PRINT "-X";STR$(I);"*X";STR$(I);
NEXT I
PRINT
PRINT "IF S > 0 THEN"
PRINT "LET FUNC=SQR(S)"
PRINT "ELSE"
PRINT "LET FUNC=0"
PRINT "END IF"
PRINT "END FUNCTION"
ELSE
FOR N=2 TO MAXLEVEL
PRINT TAB(8+KETA/2);"ʬÅÀ";TAB(8+KETA*1.5);" ½Å¤ß"
CALL LEGENDREPARA(N,X,W)
FOR I=1 TO N
PRINT "No.";I;":";
PRINT USING "#." & REPEAT$("#",KETA):X(I);
PRINT " ";
PRINT USING "#." & REPEAT$("#",KETA) & "^^^^":W(I)
NEXT I
NEXT N
END IF
END
EXTERNAL SUB LEGENDREPOLY(KK,NEWP()) !'¥ë¥¸¥ã¥ó¥É¥ë¿¹à¼°(·¸¿ô)
OPTION ARITHMETIC DECIMAL_HIGH
OPTION BASE 0
DIM P(KK+1),OLDP(KK),PP(KK)
LET OLDP(0)=1
LET P(1)=1
FOR I=0 TO KK
LET NEWP(I)=0
NEXT I
FOR K=2 TO KK
FOR J=1 TO K
LET NEWP(J)=NEWP(J)+(2*K-1)/K*P(J-1)
LET NEWP(J-1)=NEWP(J-1)-(K-1)/K*OLDP(J-1)
NEXT J
IF K < KK THEN
FOR I=0 TO K
LET OLDP(I)=P(I)
LET P(I)=NEWP(I)
LET NEWP(I)=0
NEXT I
END IF
NEXT K
END SUB
EXTERNAL FUNCTION LEGENDRE(K,X) !'¥ë¥¸¥ã¥ó¥É¥ë¿¹à¼°(ÃÍ)
OPTION ARITHMETIC DECIMAL_HIGH
OPTION BASE 0
DIM PP(K+1)
LET PP(0)=1
LET PP(1)=X
FOR N=1 TO K-1
LET PP(N+1)=((2*N+1)*X*PP(N)-N*PP(N-1))/(N+1)
NEXT N
LET LEGENDRE=PP(K)
END FUNCTION
EXTERNAL FUNCTION WEIGHT(N,X) !'½Å¤ß
OPTION ARITHMETIC DECIMAL_HIGH
LET WEIGHT=2*(1-X^2)/(N*LEGENDRE(N-1,X))^2
END FUNCTION
EXTERNAL FUNCTION HORNER(N,A(),X)
OPTION ARITHMETIC DECIMAL_HIGH
LET Y=A(N)
FOR I=N-1 TO 0 STEP -1
LET Y=Y*X+A(I)
NEXT I
LET HORNER=Y
END FUNCTION
EXTERNAL SUB DERIVATIVE(A(),B()) !'Èùʬ
OPTION ARITHMETIC DECIMAL_HIGH
FOR I=MAXLEVEL TO 1 STEP -1
LET B(I-1)=I*A(I)
NEXT I
LET B(MAXLEVEL)=0
END SUB
EXTERNAL SUB COPY(X(),Y())
OPTION ARITHMETIC DECIMAL_HIGH
FOR I=0 TO MAXLEVEL
LET X(I)=Y(I)
NEXT I
END SUB
---------------------------------------------------
¥ë¥¸¥ã¥ó¥É¥ë¿¹à¼°É½¼¨
ÍÍý¿ô¥â¡¼¥É¤Ç¤ª»î¤·¤¯¤À¤µ¤¤
OPTION BASE 0
PUBLIC NUMERIC MAXLEVEL
LET MAXLEVEL=20 !'¼¡¿ô
DIM P(MAXLEVEL)
PRINT "P(0)=1"
PRINT "P(1)=X"
FOR K=2 TO MAXLEVEL
CALL LEGENDREPOLY(K,P) !'¾åµ»²¾È(OPTION ARITHMETIC DECIMAL_HIGH¤ò³°¤¹)
PRINT "P(";STR$(K);")=";
CALL DISPLAY(P)
NEXT K
END
EXTERNAL SUB DISPLAY(A())
FOR N=MAXLEVEL TO 0 STEP -1
IF A(N)<>0 THEN EXIT FOR
NEXT N
IF N > 1 THEN
IF A(N) < 0 THEN PRINT "-";
IF ABS(A(N))<>1 THEN
PRINT STR$(ABS(A(N)));"*X^";STR$(N);
ELSE
PRINT "X^";STR$(N);
END IF
END IF
FOR I=N-1 TO 2 STEP -1
IF A(I)<>0 THEN
IF A(I) < 0 THEN PRINT "-"; ELSE PRINT "+";
IF ABS(A(I))<>1 THEN
PRINT STR$(ABS(A(I)));"*X^";STR$(I);
ELSEIF ABS(A(I))=1 THEN
PRINT "X^";STR$(I);
END IF
END IF
NEXT I
IF A(1)<>0 THEN
IF N > 1 THEN
IF A(1) < 0 THEN PRINT "-"; ELSE PRINT "+";
END IF
IF ABS(A(1))<>1 THEN
PRINT STR$(ABS(A(1)));"*X";
ELSEIF ABS(A(1))=1 THEN
PRINT "X";
END IF
END IF
IF A(0)<>0 THEN
IF A(0) < 0 THEN PRINT "-"; ELSE PRINT "+";
PRINT STR$(ABS(A(0)));
END IF
PRINT
END SUB
OPTION BASE 0
OPTION ARITHMETIC DECIMAL_HIGH
PUBLIC NUMERIC MAXLEVEL,EPS
LET MAXLEVEL=10
DIM X(MAXLEVEL),W(MAXLEVEL)
LET KETA=16
LET EPS=10^(-KETA)
LET DISPMODE=0 !' 0 or else
LET INTEGRAL=1 !' INTEGRAL >= 1
IF DISPMODE<>0 THEN
CALL LAGUERREPARA(MAXLEVEL,X,W)
PRINT "DIM X(";STR$(MAXLEVEL);"),W(";STR$(MAXLEVEL);")"
PRINT "FOR I=1 TO";MAXLEVEL
PRINT "READ X(I),W(I)"
PRINT "NEXT"
FOR I=1 TO INTEGRAL
PRINT "INPUT PROMPT ";CHR$(34);"GAMMA(";
FOR J=1 TO INTEGRAL
PRINT "X";STR$(J);
IF J < INTEGRAL THEN PRINT ",";
NEXT J
PRINT ") X";STR$(I);"=";CHR$(34);":U";STR$(I)
NEXT I
PRINT "LET S=0"
FOR I=1 TO INTEGRAL
PRINT "FOR I";STR$(I);"=1 TO";MAXLEVEL
NEXT I
PRINT "LET S=S+";
FOR I=1 TO INTEGRAL
PRINT "W(I";STR$(I);")*";
NEXT I
PRINT "FUNC(";
FOR I=1 TO INTEGRAL
PRINT "X(I";STR$(I);"),";
NEXT I
FOR I=1 TO INTEGRAL
PRINT "U";STR$(I);
IF I < INTEGRAL THEN PRINT ",";
NEXT I
PRINT ")*EXP(";
FOR I=1 TO INTEGRAL
PRINT "X(I";STR$(I);")";
IF I < INTEGRAL THEN PRINT "+";
NEXT I
PRINT ")"
FOR I=1 TO INTEGRAL
PRINT "NEXT"
NEXT I
PRINT "PRINT S"
FOR I=1 TO MAXLEVEL
PRINT "DATA ";
PRINT USING "##." & REPEAT$("#",KETA):X(I);
PRINT ",";
PRINT USING "#." & REPEAT$("#",KETA) & "^^^^":W(I)
NEXT I
PRINT "END"
PRINT
PRINT "EXTERNAL FUNCTION FUNC(";
FOR I=1 TO INTEGRAL
PRINT "X";STR$(I);",";
NEXT I
FOR I=1 TO INTEGRAL
PRINT "U";STR$(I);
IF I < INTEGRAL THEN PRINT ",";
NEXT I
PRINT ")"
PRINT "FUNC=";
FOR I=1 TO INTEGRAL
PRINT "EXP(-X";STR$(I);")*X";STR$(I);"^(U";STR$(I);"-1)";
IF I < INTEGRAL THEN PRINT "*";
NEXT I
PRINT
PRINT "END FUNCTION"
ELSE
FOR N=2 TO MAXLEVEL
CALL LAGUERREPARA(N,X,W)
PRINT TAB(8+KETA/2);"ʬÅÀ";TAB(8+KETA*1.5);" ½Å¤ß"
FOR I=1 TO N
PRINT "No.";I;":";
PRINT USING "##." & REPEAT$("#",KETA):X(I);
PRINT " ";
PRINT USING "#." & REPEAT$("#",KETA) & "^^^^":W(I)
NEXT I
NEXT N
END IF
END
EXTERNAL SUB LAGUERREPARA(N,A(),W())
OPTION ARITHMETIC DECIMAL_HIGH
OPTION BASE 0
DIM LA(MAXLEVEL+1),D(MAXLEVEL)
CALL LAGUERREPOLY(N,LA)
FOR I=0 TO N
LET LA(I)=LA(I)/LA(N)
NEXT I
FOR I=1 TO N
CALL DERIVATIVE(LA,D)
LET XX=0
DO
LET X=XX
LET XX=X-HORNER(N,LA,X)/HORNER(N,D,X)
LOOP UNTIL ABS(HORNER(N,LA,XX)) < EPS AND ABS(X-XX) < EPS
LET A(I)=XX
LET W(I)=WEIGHT(N,XX)
CALL DIV(LA,XX)
NEXT I
END SUB
EXTERNAL SUB LAGUERREPOLY(N,NEWP()) !'¥é¥²¡¼¥ë¿¹à¼°(·¸¿ô)
OPTION ARITHMETIC DECIMAL_HIGH
OPTION BASE 0
DIM P(N+1),OLDP(N)
LET OLDP(0)=1
LET P(1)=-1
LET P(0)=1
FOR I=0 TO N
LET NEWP(I)=0
NEXT I
FOR K=2 TO N
FOR J=0 TO K
LET NEWP(J)=NEWP(J)+(2*K-1)*P(J)-(K-1)^2*OLDP(J)
LET NEWP(J+1)=NEWP(J+1)-P(J)
NEXT J
IF K < N THEN
FOR I=0 TO K
LET OLDP(I)=P(I)
LET P(I)=NEWP(I)
LET NEWP(I)=0
NEXT I
END IF
NEXT K
END SUB
EXTERNAL FUNCTION LAGUERRE(NN,X) !'¥é¥²¡¼¥ë¿¹à¼°(ÃÍ)
OPTION ARITHMETIC DECIMAL_HIGH
OPTION BASE 0
DIM L(NN+1)
LET L(0)=1
LET L(1)=1-X
FOR N=1 TO NN-1
LET L(N+1)=(2*N+1-X)*L(N)-N*N*L(N-1)
NEXT N
LET LAGUERRE=L(NN)
END FUNCTION
EXTERNAL FUNCTION WEIGHT(N,X)
OPTION ARITHMETIC DECIMAL_HIGH
LET WEIGHT=FAC(N)^2/(X*LAGUERREDIFF(N,X)^2)
END FUNCTION
EXTERNAL FUNCTION LAGUERREDIFF(N,X)
OPTION ARITHMETIC DECIMAL_HIGH
LET LAGUERREDIFF=(LAGUERRE(N+1,X)-(N+1-X)*LAGUERRE(N,X))/X
END FUNCTION
EXTERNAL FUNCTION FAC(X)
OPTION ARITHMETIC DECIMAL_HIGH
LET S=1
FOR I=2 TO X
LET S=S*I
NEXT I
LET FAC=S
END FUNCTION
EXTERNAL SUB DERIVATIVE(A(),B())
OPTION ARITHMETIC DECIMAL_HIGH
FOR I=MAXLEVEL TO 1 STEP -1
LET B(I-1)=I*A(I)
NEXT I
LET B(MAXLEVEL)=0
END SUB
EXTERNAL FUNCTION HORNER(N,A(),X)
OPTION ARITHMETIC DECIMAL_HIGH
LET Y=A(N)
FOR I=N-1 TO 0 STEP -1
LET Y=Y*X+A(I)
NEXT I
LET HORNER=Y
END FUNCTION
EXTERNAL SUB DIV(A(),P)
OPTION BASE 0
OPTION ARITHMETIC DECIMAL_HIGH
DIM C(MAXLEVEL)
FOR I=MAXLEVEL TO 1 STEP -1
LET C(I-1)=A(I)+C(I)*P
NEXT I
CALL COPY(A,C)
END SUB
EXTERNAL SUB COPY(X(),Y())
OPTION ARITHMETIC DECIMAL_HIGH
FOR I=0 TO MAXLEVEL
LET X(I)=Y(I)
NEXT I
END SUB
OPTION BASE 0
OPTION ARITHMETIC DECIMAL_HIGH
PUBLIC NUMERIC MAXLEVEL,EPS
LET MAXLEVEL=10
DIM X(MAXLEVEL),W(MAXLEVEL)
LET KETA=16
LET EPS=10^(-KETA)
LET DISPMODE=0 !' 0 or else
LET INTEGRAL=1 !' INTEGRAL >= 1
IF DISPMODE<>0 THEN
CALL HERMITEPARA(MAXLEVEL,X,W)
PRINT "DIM X(";STR$(MAXLEVEL);"),W(";STR$(MAXLEVEL);")"
PRINT "FOR I=1 TO";MAXLEVEL
PRINT "READ X(I),W(I)"
PRINT "NEXT"
PRINT "LET S=0"
FOR I=1 TO INTEGRAL
PRINT "FOR I";STR$(I);"=1 TO";MAXLEVEL
NEXT I
PRINT "LET S=S+";
FOR I=1 TO INTEGRAL
PRINT "W(I";STR$(I);")*";
NEXT I
PRINT "FUNC(";
FOR I=1 TO INTEGRAL
PRINT "X(I";STR$(I);")";
IF I < INTEGRAL THEN PRINT ",";
NEXT I
PRINT ")*EXP(";
FOR I=1 TO INTEGRAL
PRINT "X(I";STR$(I);")^2";
IF I < INTEGRAL THEN PRINT "+";
NEXT I
PRINT ")"
FOR I=1 TO INTEGRAL
PRINT "NEXT"
NEXT I
PRINT "PRINT S,PI^";STR$(INTEGRAL/2)
FOR I=1 TO MAXLEVEL
PRINT "DATA ";
PRINT USING "##." & REPEAT$("#",KETA):X(I);
PRINT ",";
PRINT USING "#." & REPEAT$("#",KETA) & "^^^^":W(I)
NEXT I
PRINT "END"
PRINT
PRINT "EXTERNAL FUNCTION FUNC(";
FOR I=1 TO INTEGRAL
PRINT "X";STR$(I);
IF I < INTEGRAL THEN PRINT ",";
NEXT I
PRINT ")"
PRINT "LET FUNC=EXP(";
FOR I=1 TO INTEGRAL
PRINT "-X";STR$(I);"^2";
NEXT I
PRINT ")"
PRINT "END FUNCTION"
ELSE
FOR N=2 TO MAXLEVEL
CALL HERMITEPARA(N,X,W)
PRINT TAB(8+KETA/2);"ʬÅÀ";TAB(8+KETA*1.5);" ½Å¤ß"
FOR I=1 TO N
PRINT "No.";I;":";
PRINT USING "##." & REPEAT$("#",KETA):X(I);
PRINT " ";
PRINT USING "#." & REPEAT$("#",KETA) & "^^^^":W(I)
NEXT I
NEXT N
END IF
END
EXTERNAL SUB HERMITEPARA(N,A(),W())
OPTION ARITHMETIC DECIMAL_HIGH
OPTION BASE 0
DIM H(MAXLEVEL),D(MAXLEVEL)
CALL HERMITEPOLY(N,H)
FOR I=0 TO N
LET H(I)=H(I)/H(N)
NEXT I
FOR I=1 TO N
CALL DERIVATIVE(H,D)
LET XX=-15
DO
LET X=XX
LET XX=X-HORNER(N,H,X)/HORNER(N,D,X)
LOOP UNTIL ABS(HORNER(N,H,XX)) < EPS AND ABS(X-XX) < EPS
LET A(I)=XX
LET W(I)=WEIGHT(N,XX)
CALL DIV(H,XX)
NEXT I
END SUB
EXTERNAL SUB HERMITEPOLY(N,NEWP()) !'¥¨¥ë¥ß¡¼¥È¿¹à¼°(·¸¿ô)
OPTION ARITHMETIC DECIMAL_HIGH
OPTION BASE 0
DIM P(N+1),OLDP(N)
LET OLDP(0)=1
LET P(1)=2
FOR I=0 TO N
LET NEWP(I)=0
NEXT I
FOR K=2 TO N
FOR J=1 TO K
LET NEWP(J)=NEWP(J)+2*P(J-1)
LET NEWP(J-1)=NEWP(J-1)-2*(K-1)*OLDP(J-1)
NEXT J
IF K < N THEN
FOR I=0 TO K
LET OLDP(I)=P(I)
LET P(I)=NEWP(I)
LET NEWP(I)=0
NEXT I
END IF
NEXT K
END SUB
EXTERNAL FUNCTION HERMITE(NN,X) !'¥¨¥ë¥ß¡¼¥È¿¹à¼°(ÃÍ)
OPTION ARITHMETIC DECIMAL_HIGH
OPTION BASE 0
DIM H(NN+1)
LET H(0)=1
LET H(1)=2*X
FOR N=1 TO NN-1
LET H(N+1)=2*X*H(N)-2*N*H(N-1)
NEXT N
LET HERMITE=H(NN)
END FUNCTION
EXTERNAL FUNCTION WEIGHT(N,X) !'½Å¤ß
OPTION ARITHMETIC DECIMAL_HIGH
LET WEIGHT=2^(N+1)*FAC(N)*SQR(PI)/HERMITE(N+1,X)^2
END FUNCTION
EXTERNAL FUNCTION FAC(X)
OPTION ARITHMETIC DECIMAL_HIGH
LET S=1
FOR I=2 TO X
LET S=S*I
NEXT I
LET FAC=S
END FUNCTION
EXTERNAL FUNCTION HORNER(N,A(),X)
OPTION ARITHMETIC DECIMAL_HIGH
LET Y=A(N)
FOR I=N-1 TO 0 STEP -1
LET Y=Y*X+A(I)
NEXT I
LET HORNER=Y
END FUNCTION
EXTERNAL SUB DERIVATIVE(A(),B())
OPTION ARITHMETIC DECIMAL_HIGH
FOR I=MAXLEVEL TO 1 STEP -1
LET B(I-1)=I*A(I)
NEXT I
LET B(MAXLEVEL)=0
END SUB
EXTERNAL SUB DIV(A(),P)
OPTION BASE 0
OPTION ARITHMETIC DECIMAL_HIGH
DIM C(MAXLEVEL)
FOR I=MAXLEVEL TO 1 STEP -1
LET C(I-1)=A(I)+C(I)*P
NEXT I
CALL COPY(A,C)
END SUB
EXTERNAL SUB COPY(X(),Y())
OPTION ARITHMETIC DECIMAL_HIGH
FOR I=0 TO MAXLEVEL
LET X(I)=Y(I)
NEXT I
END SUB
PUBLIC NUMERIC MAXLEVEL
OPTION BASE 0
LET MAXLEVEL=10 !'ºÇÂ缡¿ô (MAXLEVEL > N)
LET N=5 !'¥Ç¡¼¥¿¿ô
DIM X(N),Y(N),A(MAXLEVEL),B(MAXLEVEL)
FOR I=1 TO N
READ X(I),Y(I) !'y=x^2
NEXT I
CALL LARGRANGE(N,X,Y,A) !'¥é¥°¥é¥ó¥¸¥å¿¹à¼°
CALL INTEGRAL(A,B) !'ÀÑʬ
PRINT HORNER(N,B,X(N))-HORNER(N,B,X(1));X(N)^3/3-X(1)^3/3
!'CALL DERIVATIVE(A,B) !'Èùʬ
!'INPUT PROMPT "f'(x) x=":XX
!'PRINT HORNER(N,B,XX);2*XX
DATA 0,0 !'Î¥»¶Ãͥǡ¼¥¿ XÃͤÏÅù´Ö³Ö¤Ç¤Ê¤¯¤Æ¤â¤¤¤¤
DATA 1,1
DATA 3,9
DATA 4,16
DATA 6,36
END
EXTERNAL SUB LARGRANGE(N,X(),Y(),A())
OPTION BASE 0
DIM U(MAXLEVEL),V(MAXLEVEL)
CALL CLR(A)
LET U(1)=1
FOR I = 1 TO N
LET R = Y(I)
CALL CLR(V)
LET V(0)=1
FOR J = 1 TO N
IF I <> J THEN
LET U(0)=-X(J)
CALL MUL(V,U)
LET R = R / (X(I)-X(J))
END IF
NEXT J
CALL SHORTMUL(V,R)
CALL ADD(A,V)
NEXT I
END SUB
EXTERNAL FUNCTION HORNER(N,A(),XX)
LET Y=A(N)
FOR I=N-1 TO 0 STEP -1
LET Y=Y*XX+A(I)
NEXT I
LET HORNER=Y
END FUNCTION
EXTERNAL SUB MUL(A(),B())
OPTION BASE 0
DIM C(MAXLEVEL)
FOR I=0 TO MAXLEVEL-1
FOR J=0 TO 1
LET C(I+J)=C(I+J)+A(I)*B(J)
NEXT J
NEXT I
CALL COPY(A,C)
END SUB
EXTERNAL SUB INTEGRAL(A(),B())
FOR I=MAXLEVEL-1 TO 0 STEP -1
LET B(I+1)=A(I)/(I+1)
NEXT I
LET B(0)=0
END SUB
EXTERNAL SUB ADD(A(),B())
FOR I=0 TO MAXLEVEL
LET A(I)=A(I)+B(I)
NEXT I
END SUB
EXTERNAL SUB COPY(X(),Y())
FOR I=0 TO MAXLEVEL
LET X(I)=Y(I)
NEXT I
END SUB
EXTERNAL SUB CLR(X())
FOR I=0 TO MAXLEVEL
LET X(I)=0
NEXT I
END SUB
EXTERNAL SUB SHORTMUL(A(),X)
FOR I=0 TO MAXLEVEL
LET A(I)=A(I)*X
NEXT I
END SUB
EXTERNAL SUB DERIVATIVE(A(),B())
FOR I=MAXLEVEL TO 1 STEP -1
LET B(I-1)=I*A(I)
NEXT I
LET B(MAXLEVEL)=0
END SUB
LET N=5 !'¥Ç¡¼¥¿¿ô ¾ò·ï...MOD(N-1,M-1)=0
LET M=3 !'¾®¶è´Ö ´Ö³Ö¿ô
DIM X(N),Y(N),XX(M),YY(M)
FOR I=1 TO N
READ X(I),Y(I) !'y=x^2
NEXT I
LET S=0
FOR I=1 TO N-M+1 STEP M-1 !'¾®¶è´Ö¤Ëʬ³ä¤¹¤ë X(1)¡ÁX(3),X(3)¡ÁX(5),X(5)¡ÁX(7),...
FOR K=0 TO M-1
LET XX(K+1)=X(I+K)
LET YY(K+1)=Y(I+K)
NEXT K
LET S=S+INTEGRAL(XX,YY,M) !'Á´¶è´Öʬ¤ò¤·¹ç¤ï¤»¤ë
!'LET SS=SS+INTEGRAL2(XX,YY,M) !'²¼µ»²¾È
NEXT I
PRINT S;(X(N)^3-X(1)^3)/3 !' ;SS
!'INPUT PROMPT "f'(x) x=":XX
!'PRINT DERIVATIVE(N,X,Y,XX);2*XX !'²¼µ»²¾È
DATA 0,0 !'Î¥»¶Ãͥǡ¼¥¿ XÃͤÏÅù´Ö³Ö¤Ç¤Ê¤¯¤Æ¤â¤¤¤¤
DATA 1,1
DATA 3,9
DATA 4,16
DATA 6,36
END
EXTERNAL FUNCTION INTEGRAL(X(),Y(),M)
DECLARE EXTERNAL FUNCTION COMB
DIM H(M),XX(M),TEMP(M)
FOR I=1 TO M
LET H(I)=1
LET K=0
FOR J=1 TO M
IF I<>J THEN
LET H(I)=H(I)/(X(I)-X(J))
LET K=K+1
LET XX(K)=X(J)
END IF
NEXT J
LET SIGN=1
FOR J=M TO 1 STEP -1
LET SM=SM+SIGN*X(M)^J/J*COMB(XX,M,M-J,TEMP,1)*H(I)*Y(I)
LET S1=S1+SIGN*X(1)^J/J*COMB(XX,M,M-J,TEMP,1)*H(I)*Y(I)
LET SIGN=-SIGN
NEXT J
NEXT I
LET INTEGRAL=SM-S1
END FUNCTION
EXTERNAL FUNCTION COMB(X(),N,R,A(),K)
IF R=0 THEN
LET S=1
FOR I=1 TO N
IF A(I)=1 THEN LET S=S*X(I)
NEXT I
LET COMB=S
ELSE
FOR I=K TO N-R+1
LET A(I)=1
LET SS=SS+COMB(X,N,R-1,A,I+1)
LET A(I)=0
NEXT I
LET COMB=SS
END IF
END FUNCTION
EXTERNAL FUNCTION INTEGRAL2(X(),Y(),N)
DIM A(N,N),B(N)
FOR I=1 TO N
FOR J=1 TO N
LET A(I,J)=X(J)^(I-1)
NEXT J
LET B(I)=(X(N)^I-X(1)^I)/I
NEXT I
MAT A=INV(A)
MAT B=A*B
FOR I=1 TO N
LET S=S+B(I)*Y(I)
NEXT I
LET INTEGRAL2=S
END FUNCTION
EXTERNAL FUNCTION DERIVATIVE(N,X(),Y(),XX)
DIM A(N,N),B(N)
FOR I=1 TO N
FOR J=1 TO N
LET A(I,J)=X(J)^I
NEXT J
LET B(I)=I*XX^(I-1)
!'LET B(I)=I*(I-1)*XX^(I-2) !'2³¬Èùʬ
NEXT I
MAT A=INV(A)
MAT B=A*B
FOR I=1 TO N
LET S=S+B(I)*Y(I)
NEXT I
LET DERIVATIVE=S
END FUNCTION
EXTERNAL FUNCTION DIFF(N,X(),Y(),XX)
DIM A(N)
FOR I=1 TO N
LET L=1
LET KK=0
FOR J=1 TO N
IF J<>I THEN
LET KK=KK+1
LET L=L*(X(I)-X(J))
LET A(KK)=X(J)
END IF
NEXT J
LET S1=0
FOR J=1 TO N-1
LET S=1
FOR K=1 TO N-1
IF K<>J THEN LET S=S*(XX-A(K))
NEXT K
LET S1=S1+S
NEXT J
LET SS=SS+S1*Y(I)/L
NEXT I
LET DIFF=SS
END FUNCTION
PUBLIC NUMERIC LEVEL
INPUT PROMPT "¿½ÅÀÑʬ LEVEL=":LEVEL
DIM A(LEVEL),B(LEVEL),N(LEVEL),AA(LEVEL)
FOR I=1 TO LEVEL
!'INPUT PROMPT "²¼¸Â =":A(I)
!'INPUT PROMPT "¾å¸Â =":B(I)
!'INPUT PROMPT "ʬ³ä¿ô=":N(I)
READ A(I),B(I),N(I)
NEXT I
DATA 0,1,10
DATA 0,1,10
DATA 0,1,10
DATA 0,1,10
PRINT SIMPSONRECURSIVE(LEVEL,AA,A,B,N)
END
EXTERNAL FUNCTION SIMPSONRECURSIVE(LEV,AA(),A(),B(),N())
IF LEV=0 THEN
LET SIMPSONRECURSIVE=FUNC(AA)
ELSE
LET H=(B(LEV)-A(LEV))/N(LEV)/2
FOR K=0 TO N(LEV)-1
LET AA(LEV)=A(LEV)+H*K*2
LET S=S+1/3*H*SIMPSONRECURSIVE(LEV-1,AA,A,B,N)
LET AA(LEV)=A(LEV)+H*(2*K+1)
LET S=S+4/3*H*SIMPSONRECURSIVE(LEV-1,AA,A,B,N)
LET AA(LEV)=A(LEV)+H*(2*K+2)
LET S=S+1/3*H*SIMPSONRECURSIVE(LEV-1,AA,A,B,N)
NEXT K
LET SIMPSONRECURSIVE=S
END IF
END FUNCTION
EXTERNAL FUNCTION FUNC(X())
LET S=1
FOR I=1 TO LEVEL
LET S=S-X(I)*X(I)
NEXT I
IF S > 0 THEN
LET FUNC=SQR(S)
ELSE
LET FUNC=0
END IF
END FUNCTION
PUBLIC NUMERIC W(10),X(10),LEVEL
INPUT PROMPT "¿½ÅÀÑʬ LEVEL=":LEVEL
DIM A(LEVEL),B(LEVEL),XX(LEVEL),WW(LEVEL)
FOR I=1 TO LEVEL
READ A(I),B(I)
NEXT I
DATA 0,1
DATA 0,1
DATA 0,1
DATA 0,1
RESTORE 10
FOR I=1 TO 10
READ X(I),W(I)
NEXT I
PRINT LEGENDRERECURSIVE(LEVEL,XX,WW,A,B,10)
10 DATA -.9739065285171717,6.6671344308688138E-02 !'10ÅÀ ¥ë¥¸¥ã¥ó¥É¥ë§
DATA -.8650633666889845,1.4945134915058059E-01
DATA -.6794095682990244,2.1908636251598204E-01
DATA -.4333953941292472,2.6926671930999636E-01
DATA -.1488743389816312,2.9552422471475287E-01
DATA .1488743389816312,2.9552422471475287E-01
DATA .4333953941292472,2.6926671930999636E-01
DATA .6794095682990244,2.1908636251598204E-01
DATA .8650633666889845,1.4945134915058059E-01
DATA .9739065285171717,6.6671344308688138E-02
END
EXTERNAL FUNCTION LEGENDRERECURSIVE(LEV,XX(),WW(),A(),B(),N)
IF LEV=0 THEN
LET LEGENDRERECURSIVE=FUNC(XX)
ELSE
FOR I=1 TO N
LET XX(LEV)=X(I)*(B(LEV)-A(LEV))/2+(A(LEV)+B(LEV))/2
LET WW(LEV)=W(I)*(B(LEV)-A(LEV))/2
LET S=S+LEGENDRERECURSIVE(LEV-1,XX,WW,A,B,N)*WW(LEV)
NEXT I
LET LEGENDRERECURSIVE=S
END IF
END FUNCTION
EXTERNAL FUNCTION FUNC(X())
LET S=1
FOR I=1 TO LEVEL
LET S=S-X(I)*X(I)
NEXT I
IF S > 0 THEN
LET FUNC=SQR(S)
ELSE
LET FUNC=0
END IF
END FUNCTION
PUBLIC NUMERIC LEVEL
INPUT PROMPT "¿½ÅÀÑʬ LEVEL=":LEVEL
DIM A(LEVEL),B(LEVEL),N(LEVEL),X(LEVEL),W(LEVEL)
FOR I=1 TO LEVEL
!'INPUT PROMPT "²¼¸Â =":A(I)
!'INPUT PROMPT "¾å¸Â =":B(I)
!'INPUT PROMPT "ʬ³ä¿ô=":N(I)
READ A(I),B(I),N(I)
NEXT I
DATA 0,1,10
DATA 0,1,10
DATA 0,1,10
DATA 0,1,10
PRINT TCHEBYCHEFFRECURSIVE(LEVEL,X,W,A,B,N)
END
EXTERNAL FUNCTION TCHEBYCHEFFRECURSIVE(LEV,XX(),WW(),A(),B(),N())
IF LEV=0 THEN
LET TCHEBYCHEFFRECURSIVE=FUNC(XX)
ELSE
FOR I=0 TO N(LEV)-1
LET XX(LEV)=COS((2*I+1)/2/N(LEV)*PI)*(B(LEV)-A(LEV))/2+(A(LEV)+B(LEV))/2
LET WW(LEV)=SQR((B(LEV)-XX(LEV))*(XX(LEV)-A(LEV)))
LET S=S+TCHEBYCHEFFRECURSIVE(LEV-1,XX,WW,A,B,N)*WW(LEV)
NEXT I
LET TCHEBYCHEFFRECURSIVE=S*PI/N(LEV)
END IF
END FUNCTION
EXTERNAL FUNCTION FUNC(X())
LET S=1
FOR I=1 TO LEVEL
LET S=S-X(I)*X(I)
NEXT I
IF S > 0 THEN
LET FUNC=SQR(S)
ELSE
LET FUNC=0
END IF
END FUNCTION
PUBLIC NUMERIC LEVEL
INPUT PROMPT "¿½ÅÀÑʬ LEVEL=":LEVEL
DIM X(LEVEL)
PRINT DE(LEVEL,X,1/16);PI^(LEVEL/2)
END
EXTERNAL FUNCTION DE(LEV,X(),H)
IF LEV=0 THEN
LET DE=FUNC(X)
ELSE
FOR K=-4 TO 4 STEP H !'(Í×)Ä´À° K=-6¡Á6,H=1/1000 ÄøÅÙ
LET X(LEV)=Q(K)
LET S=S+H*DE(LEV-1,X,H)*QQ(K)
NEXT K
LET DE=S
END IF
END FUNCTION
EXTERNAL FUNCTION Q(X)
LET Q=SINH(PI/2*SINH(X))
END FUNCTION
EXTERNAL FUNCTION QQ(X)
LET QQ=PI/2*COSH(X)*COSH(PI/2*SINH(X))
END FUNCTION
EXTERNAL FUNCTION FUNC(X())
LET S=0
FOR I=1 TO LEVEL
LET S=S-X(I)*X(I)
NEXT I
LET FUNC=EXP(S)
END FUNCTION
RANDOMIZE
PUBLIC NUMERIC LEVEL
INPUT PROMPT "¿½ÅÀÑʬ LEVEL=":LEVEL
DIM A(LEVEL),B(LEVEL),N(LEVEL),AA(LEVEL)
FOR I=1 TO LEVEL
!'INPUT PROMPT "²¼¸Â =":A(I)
!'INPUT PROMPT "¾å¸Â =":B(I)
!'INPUT PROMPT "ʬ³ä¿ô=":N(I)
READ A(I),B(I),N(I)
NEXT I
PRINT MONTE(LEVEL,A,B,10000)
!'PRINT MONTE2(LEVEL,A,B,10000,2000)
!'PRINT MONTESIMPSON(LEVEL,A,B,10000)
!'PRINT MONTERECURSIVE(LEVEL,AA,A,B,N)
DATA 0,1,50
DATA 0,1,50
DATA 0,1,50
DATA 0,1,50
END
EXTERNAL FUNCTION MONTE(LEV,A(),B(),N)
RANDOMIZE
DIM AA(LEV)
LET H=1
FOR I=1 TO LEV
LET H=H*(B(I)-A(I))
NEXT I
FOR K=1 TO N
FOR I=1 TO LEV
LET AA(I)=A(I)+(B(I)-A(I))*RND
NEXT I
LET S=S+FUNC(AA)
NEXT K
LET MONTE=H*S/N
END FUNCTION
EXTERNAL FUNCTION MONTE2(LEV,A(),B(),N,NN)
RANDOMIZE
DIM AA(LEV)
LET HMAX=-MAXNUM
LET HMIN=MAXNUM
LET HH=1
FOR I=1 TO LEV
LET HH=HH*(B(I)-A(I))
NEXT I
FOR K=1 TO NN
FOR J=1 TO LEV
LET AA(J)=A(J)+(B(J)-A(J))*RND
NEXT J
LET H=FUNC(AA)
LET HMIN=MIN(HMIN,MIN(H,0))
LET HMAX=MAX(H,HMAX)
NEXT K
LET H=HMAX-HMIN
FOR K=1 TO N
FOR J=1 TO LEV
LET AA(J)=A(J)+(B(J)-A(J))*RND
NEXT J
LET Z=H*RND+HMIN
IF FUNC(AA) > 0 THEN
IF Z > 0 AND Z < FUNC(AA) THEN LET M1=M1+1
ELSE
IF Z < 0 AND Z > FUNC(AA) THEN LET M2=M2+1
END IF
NEXT K
LET MONTE2=HH*(M1-M2)/N*H
END FUNCTION
EXTERNAL FUNCTION MONTERECURSIVE(LEV,AA(),A(),B(),N()) !'ºÆµ¢¼°¥â¥ó¥Æ¥«¥ë¥í
IF LEV=0 THEN
LET MONTERECURSIVE=FUNC(AA)
ELSE
LET H=B(LEV)-A(LEV)
FOR K=1 TO N(LEV)
LET AA(LEV)=A(LEV)+H*RND
LET S=S+MONTERECURSIVE(LEV-1,AA,A,B,N)
NEXT K
LET MONTERECURSIVE=H*S/N(LEV)
END IF
END FUNCTION
EXTERNAL FUNCTION MONTESIMPSON(LEV,A(),B(),N) !'¥â¥ó¥Æ¥«¥ë¥í¡Ü¥·¥ó¥×¥½¥ó§
RANDOMIZE
DIM AA(LEV),T(LEV),HH(LEV)
LET H=1
FOR I=1 TO LEV
LET H=H*(B(I)-A(I))
LET HH(I)=(B(I)-A(I))/N/2
NEXT I
FOR K=1 TO N
FOR I=1 TO LEV
LET T(I)=(B(I)-A(I))*RND+A(I)
LET AA(I)=A(I)+T(I)
NEXT I
LET S=S+1/3*H*FUNC(AA)
FOR I=1 TO LEVEL
LET AA(I)=A(I)+HH(I)+T(I)
NEXT I
LET S=S+4/3*H*FUNC(AA)
FOR I=1 TO LEVEL
LET AA(I)=A(I)+2*HH(I)+T(I)
NEXT I
LET S=S+1/3*H*FUNC(AA)
NEXT K
LET MONTESIMPSON=S/N/2
END FUNCTION
EXTERNAL FUNCTION FUNC(X())
LET S=1
FOR I=1 TO LEVEL
LET S=S-X(I)*X(I)
NEXT I
IF S > 0 THEN
LET FUNC=SQR(S)
ELSE
LET FUNC=0
END IF
END FUNCTION
PUBLIC NUMERIC LEVEL
INPUT PROMPT "¿½ÅÀÑʬ LEVEL=":LEVEL
DIM X(LEVEL)
PRINT MONTEDE(LEVEL,X,10000);PI^(LEVEL/2)
END
EXTERNAL FUNCTION MONTEDE(LEV,X(),N) !'¥â¥ó¥Æ¥«¥ë¥í + DEË¡
RANDOMIZE
LET M=4 !'(Í×) Ä´À°
LET H=2*M/N
FOR J=1 TO N
LET V=1
FOR I=1 TO LEV
LET K=RND*M*2-M
LET X(I)=Q(K)
LET V=V*QQ(K)
NEXT I
LET S=S+H^LEV*FUNC(X)*V
NEXT J
LET MONTEDE=S*N^(LEV-1)
END FUNCTION
EXTERNAL FUNCTION FUNC(X())
FOR I=1 TO LEVEL
LET S=S-X(I)*X(I)
NEXT I
LET FUNC=EXP(S)
END FUNCTION
EXTERNAL FUNCTION Q(X)
LET Q=SINH(PI/2*SINH(X))
END FUNCTION
EXTERNAL FUNCTION QQ(X)
LET QQ=PI/2*COSH(X)*COSH(PI/2*SINH(X))
END FUNCTION
!' S(n+2)=V(n)*2*¦Ð*r S(n)...n¼¡¸µµå¤ÎɽÌÌÀÑ
!' V(n)=S(n)*r/n V(n)...n¼¡¸µµå¤ÎÂÎÀÑ
!' V(n)=¦Ð^(n/2)/GAMMA(n/2+1)*r^n
LET MAXLEVEL=20
DIM S(MAXLEVEL+2),V(MAXLEVEL+2)
INPUT PROMPT "Ⱦ·Â=":R !' ¸¡¾Ú»þ R=.5
LET S(2)=2*PI*R
LET V(2)=PI*R^2
LET S(3)=4*PI*R^2
LET V(3)=4/3*PI*R^3
FOR N=2 TO MAXLEVEL
LET S(N+2)=V(N)*2*PI*R
LET V(N+2)=S(N+2)*R/(N+2)
PRINT N;"¼¡¸µµå¤ÎÂÎÀÑ";V(N) !';TAB(40);"ɽÌÌÀÑ";S(N)
NEXT N
END
--- ¤ª¤Þ¤± ---
ÍÍý¿ô¥â¡¼¥É¤Ç¤ª»î¤·¤¯¤À¤µ¤¤
LET MAXLEVEL=20
DIM S(MAXLEVEL+2,3),V(MAXLEVEL+2,3)
LET S(2,1)=2
LET S(2,2)=1
LET S(2,3)=1
LET S(3,1)=4
LET S(3,2)=1
LET S(3,3)=2
LET V(2,1)=1
LET V(2,2)=1
LET V(2,3)=2
LET V(3,1)=4/3
LET V(3,2)=1
LET V(3,3)=3
FOR N=2 TO MAXLEVEL
LET S(N+2,1)=V(N,1)*2
LET S(N+2,2)=V(N,2)+1
LET S(N+2,3)=V(N,3)+1
LET V(N+2,1)=S(N+2,1)/(N+2)
LET V(N+2,2)=S(N+2,2)
LET V(N+2,3)=S(N+2,3)+1
PRINT STR$(N);"¼¡¸µµå¤ÎÂÎÀÑ ";
IF V(N,1)<>1 THEN LET A$=STR$(V(N,1)) & "*" ELSE LET A$=""
IF V(N,2)=1 THEN LET P$="¦Ð" ELSE LET P$="¦Ð^" & STR$(V(N,2))
IF V(N,3)=1 THEN LET R$="*r" ELSE LET R$="*r^" & STR$(V(N,3))
PRINT A$;P$;R$
PRINT STR$(N);"¼¡¸µµå¤ÎɽÌÌÀÑ ";
IF S(N,1)<>1 THEN LET A$=STR$(S(N,1)) & "*" ELSE LET A$=""
IF S(N,2)=1 THEN LET P$="¦Ð" ELSE LET P$="¦Ð^" & STR$(S(N,2))
IF S(N,3)=1 THEN LET R$="*r" ELSE LET R$="*r^" & STR$(S(N,3))
PRINT A$;P$;R$
PRINT
NEXT N
END
--- ¤ª¤Þ¤± 2---
!'£î¼¡¸µµå¤ÎÂÎÀÑ
!'V(n)=1/(1*3*5*7*..*N)*2^((N+1)/2)*¦Ð^((N-1)/2)*R^N ...MOD(N,2)=1
!'V(n)=1/(2*4*6*8*..*N)*2^(N/2) *¦Ð^(N/2) *R^N ...MOD(N,2)=0
LET MAXLEVEL=20
FOR N=2 TO MAXLEVEL
LET S=1
FOR I=N TO 2 STEP -2
LET S=S/I
NEXT I
PRINT N;"¼¡¸µµå¤ÎÂÎÀÑ ";STR$(S*2^((N+MOD(N,2))/2));"*¦Ð^";STR$((N-MOD(N,2))/2);"*r^";STR$(N)
PRINT N;"¼¡¸µµå¤ÎɽÌÌÀÑ ";STR$(N*S*2^((N+MOD(N,2))/2));"*¦Ð^";STR$((N-MOD(N,2))/2);"*r^";STR$(N-1)
PRINT
NEXT N
END
!£·¥»¥°¥á¥ó¥È¿ô»úɽ¼¨¤Î¥Ç¥¸¥¿¥ë»þ·×¡ÊClock¡Ë
LET w=400 !²èÌ̤ÎÂ礤µ
LET h=120
SET bitmap SIZE w+1,h+1 !¥É¥Ã¥Èñ°Ì¤Ë¤¹¤ë
SET WINDOW 0,w,h,0 !¥¯¥é¥¤¥¢¥ó¥ÈºÂɸ¡Êº¸¾å¤¬¸¶ÅÀ¡Ë
LET S0=-1
DO
LET t$=TIME$ !»þ¹ï¤òhh:mm:ss·Á¼°¤ÇÆÀ¤ë
LET S=VAL(t$(7:8)) !ÉÃ
IF S<>S0 THEN !¹¹¿·¤µ¤ì¤¿¤é
LET S0=S
LET H=VAL(t$(1:2)) !»þ
LET M=VAL(t$(4:5)) !ʬ
CALL clock_display(INT(H/10),MOD(H,10),INT(M/10),MOD(M,10),INT(S/10),MOD(S,10))
END IF
LOOP
!ÅÅ»ÒÉôÉÊ¡ÊÇÛÃÖ¤ÈÇÛÀþ¡Ë
! ¢BCD(h10,h1,m10,m1,s10,s1)
! ¨£¨¡ ¥Ç¡¼¥¿¥é¥Ã¥Á
! ¨¢ ¢BCD
! ¨¢ ¥Ç¥³¡¼¥À
! ¨¢ ¢abcdefg
! ¨¦¢ª 88:88:88
! ¨¢
! GND
SUB clock_display(h10,h1,m10,m1,s10,s1) !ɽ¼¨Éô
SET DRAW mode hidden !¤Á¤é¤Ä¤ËÉ»ß(³«»Ï)
CLEAR
DRAW LED(1,GND) WITH SCALE(20)*SHIFT(155,40) !¥³¥í¥ó
DRAW LED(1,GND) WITH SCALE(20)*SHIFT(155,80)
!¥À¥¤¥Ê¥ß¥Ã¥¯ÅÀÅôɽ¼¨
DRAW DRIVER7segment(h10) WITH SCALE(20)*SHIFT(50,60) !»þ
DRAW DRIVER7segment(h1) WITH SCALE(20)*SHIFT(110,60)
DRAW DRIVER7segment(m10) WITH SCALE(20)*SHIFT(200,60) !ʬ
DRAW DRIVER7segment(m1) WITH SCALE(20)*SHIFT(260,60)
DRAW DRIVER7segment(s10) WITH SCALE(15)*SHIFT(320,70) !ÉÃ
DRAW DRIVER7segment(s1) WITH SCALE(15)*SHIFT(370,70)
SET DRAW mode explicit !¤Á¤é¤Ä¤ËÉ»ß(½ªÎ»)
END SUB
PICTURE DRIVER7segment(BCD) !£·¥»¥°¥á¥ó¥È¿ô»úɽ¼¨¤Ë¤¹¤ë
CALL DECODE7segment(BCD, Za,Zb,Zc,Zd,Ze,Zf,Zg)
DRAW LED7segmentKwithoutDP(Za,Zb,Zc,Zd,Ze,Zf,Zg)
END PICTURE
!ÅÅ»ÒÉôÉʡʾå°Ì¡Ë
SUB DECODE7segment(n, Za,Zb,Zc,Zd,Ze,Zf,Zg) !£·¥»¥°¥á¥ó¥È¿ô»úɽ¼¨¥Ç¥³¡¼¥À
IF n=0 THEN
LET ptn$="1111110" !abcdedfg¤Î¥ª¥ó¡¦¥ª¥Õ¾õÂÖ
ELSEIF n=1 THEN
LET ptn$="0110000"
ELSEIF n=2 THEN
LET ptn$="1101101"
ELSEIF n=3 THEN
LET ptn$="1111001"
ELSEIF n=4 THEN
LET ptn$="0110011"
ELSEIF n=5 THEN
LET ptn$="1011011"
ELSEIF n=6 THEN
LET ptn$="1011111"
ELSEIF n=7 THEN
LET ptn$="1110000"
ELSEIF n=8 THEN
LET ptn$="1111111"
ELSEIF n=9 THEN
LET ptn$="1111011"
ELSE
PRINT "ÉÔÀµ¤ÊÃͤǤ¹¡£"; n
END IF
LET Za=VAL(ptn$(1:1))
LET Zb=VAL(ptn$(2:2))
LET Zc=VAL(ptn$(3:3))
LET Zd=VAL(ptn$(4:4))
LET Ze=VAL(ptn$(5:5))
LET Zf=VAL(ptn$(6:6))
LET Zg=VAL(ptn$(7:7))
END SUB
! --a- ÇÛÃÖ°ÌÃÖ
! f| |b
! --g-
! e| |c
! --d-
PICTURE LED7segmentKwithoutDP(a,b,c,d,e,f,g) !£·¥»¥°¥á¥ó¥È¿ô»úɽ¼¨´ï ¢¨¥«¥½¡¼¥É¡¦¥³¥â¥ó
DRAW bar(a,GND) WITH SHIFT(0,-2) !¢¨º¸¾å¤¬¸¶ÅÀ
DRAW bar(b,GND) WITH ROTATE(PI/2)*SHIFT(1,-1)
DRAW bar(c,GND) WITH ROTATE(PI/2)*SHIFT(1,1)
DRAW bar(d,GND) WITH SHIFT(0,2)
DRAW bar(e,GND) WITH ROTATE(PI/2)*SHIFT(-1,1)
DRAW bar(f,GND) WITH ROTATE(PI/2)*SHIFT(-1,-1)
DRAW bar(g,GND) WITH SHIFT(0,0)
END PICTURE
!ÅÅ»ÒÉôÉʡʲ¼°Ì¡Ë
PICTURE bar(a,k) !ȯ¸÷¥À¥¤¥ª¡¼¥É¤òɽ¼¨¤¹¤ë
IF a=1 AND k=0 THEN
PLOT AREA: -1,-0.3; 1,-0.3; 1,0.3; -1,0.3 !ÅÀÅô¡¡¢¨ÅɤêÄÙ¤·
ELSE
PLOT LINES: -1,-0.2; 1,-0.2; 1,0.2; -1,0.2; -1,-0.2 !¾ÃÅô¡¡¢¨ÏÈ
END IF
END PICTURE
PICTURE LED(a,k) !ȯ¸÷¥À¥¤¥ª¡¼¥É¤òɽ¼¨¤¹¤ë
IF a=1 AND k=0 THEN
DRAW disk WITH SCALE(0.4) !ÅÀÅô
ELSE
DRAW circle WITH SCALE(0.4) !¾ÃÅô
END IF
END PICTURE
END
!¡¡»³Ã椵¤ó¤Î£·¥»¥°¿ô»ú¤Ç¡¢µ¤¤¬ÉÕ¤¤¤¿¡£¤¢¤ê¤¬¤È¤¦¤´¤¶¤¤¤Þ¤¹¡£
!¡¡plot_lines ¤Î¡¢vector_font¤Ç¡¢PLOT TEXT ¤ò¡¢¥«¥Ð¡¼¤Ç¤¤¿¡£
!¡¡¤ä¤äĹʸ¤È¡¢¤ä¤»¤¿»ú·Á¤ÏÆñÅÀ¤Ê¤¬¤é¡¢»þ·×¤Î¿ô»ú¤â¡¢¶ÀÁü¤Ë¤Ê¤Ã¤¿¡£
!
!-------------------
LET N=2
LET NN=2^N
SET WINDOW -250/NN,250/NN,250/NN,-250/NN
SET TEXT COLOR 4
SET TEXT BACKGROUND "OPAQUE"
LET ¦Õ=0
LET stp=-PI/180*6
DO
LET t=INT(TIME)
IF t0<>t THEN
LET t0=t
IF 2*PI<=ABS(¦Õ) THEN LET stp=-stp
LET ¦Õ=REMAINDER(¦Õ, 2*PI) +stp
!-----
SET DRAW mode hidden
CLEAR
DRAW D4(N) WITH SHIFT(-300/2,-300/2/SQR(3))*ROTATE(¦Õ*(-1)^N)*SCALE(1,(-1)^N)
DRAW center WITH SHIFT(-300/2/NN,-300/2/NN/SQR(3))*ROTATE(¦Õ)
PLOT TEXT,AT 137/NN,-234/NN:"±¦¥¯¥ê¥Ã¥¯¤ÇÄä»ß"
SET DRAW mode explicit
ELSE
WAIT DELAY 0.05 !¡¡¾ÊÅÅÎϸú²Ì
END IF
MOUSE POLL mx,my,mlb,mrb
LOOP UNTIL mrb>=1 !¡¡±¦¥¯¥ê¥Ã¥¯¤ÇÄä»ß
PICTURE center
SET LINE COLOR 2
SET LINE width 2
PLOT LINES:0,0;300/NN,0;300/2/NN,300/2/NN*SQR(3);0,0
SET LINE width 1
SET LINE COLOR 1
END PICTURE
!------
PICTURE D4(k)
IF 0< k THEN
DRAW D4(k-1) WITH SCALE(1/2,1/2)*SHIFT(300/4,SQR(3)*300/4) !¡¡Æ⦤ξå
DRAW D4(k-1) WITH SCALE(1/2,-1/2)*SHIFT(300/4,SQR(3)*300/4) !¡¡Æ⦤ÎÃæ
DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(-PI*2/3)*SHIFT(300/4,SQR(3)*300/4) !Æ⦤κ¸
DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(PI*2/3)*SHIFT(300,0) !¡¡Æ⦤α¦
ELSE
DRAW »þ·×¿Þ WITH ROTATE(-¦Õ)*SHIFT(300/2,300/2/SQR(3))
PLOT LINES:0,0;300,0;300/2,SQR(3)*300/2;0,0 !¡¡³°Â¦¤Î´ð½à»°³Ñ·Á¡ÊľÀܤÎÉÁ²è¤Ï̵¤·¡£)
END IF
END PICTURE
!------
PICTURE »þ·×¿Þ
SET AREA COLOR 1
FOR i=1 TO 60
LET a=PI/30*(i-15)
IF MOD(i,5)=0 THEN
CALL linefont(i/5, 60*COS(a), 60*SIN(a)) !¿ô»ú
DRAW disk WITH SCALE(1)*SHIFT(72*COS(a),72*SIN(a)) !£µÊ¬ÌÜÀ¹¤ê
ELSE
DRAW disk WITH SCALE(.5)*SHIFT(72*COS(a),72*SIN(a)) !£±Ê¬ÌÜÀ¹¤ê
END IF
NEXT i
!---¡¡00:00 ¤«¤é£ôÉà ¤Î¿Ë²óž Gear
DRAW hand(1) WITH SCALE(2.5, 0.75)*ROTATE(t*PI/21600) !¡¡»þ¿Ë
DRAW hand(1) WITH ROTATE(t*PI/1800) !¡¡Ê¬¿Ë
DRAW hand(2) WITH SCALE(0, 1.1)*ROTATE(t*PI/30) !¡¡ÉÿË
!---¡¡Ãæ¿´¤Î¾þ¤ê
DRAW disk WITH SHIFT(0,0)*SCALE(4)
END PICTURE
PICTURE hand(c) !¡¡£³¿Ë¶¦ÍÑ
SET AREA COLOR c
PLOT AREA: -1,15; 1,15; 1,-60; -1,-60
END PICTURE
!-------------------------------------
SUB linefont(i,x,y) !¡¡plot text ¤ÎÂåÂØ
SELECT CASE i
CASE 1
PLOT LINES:x+2.6,y-5;x+2.6,y+5 ! 1
CASE 2
PLOT LINES:x-2.6,y-5;x+2.6,y-5;x+2.6,y;x-2.6,y;x-2.6,y+5;x+2.6,y+5 ! 2
CASE 3
PLOT LINES:x-2.6,y-5;x+2.6,y-5;x+2.6,y+5;x-2.6,y+5 ! 3a
PLOT LINES:x-2.6,y;x+2.6,y ! 3b
CASE 4
PLOT LINES:x-2.6,y-5;x-2.6,y;x+2.6,y ! 4a
PLOT LINES:x+2.6,y-5;x+2.6,y+5 ! 4b
CASE 5
PLOT LINES:x+2.6,y-5;x-2.6,y-5;x-2.6,y;x+2.6,y;x+2.6,y+5;x-2.6,y+5 ! 5
CASE 6
PLOT LINES:x+2.6,y-5;x-2.6,y-5;x-2.6,y+5;x+2.6,y+5;x+2.6,y;x-2.6,y ! 6
CASE 7
PLOT LINES:x-2.6,y-5;x+2.6,y-5;x+2.6,y+5 ! 7
CASE 8
PLOT LINES:x-2.6,y;x-2.6,y-5;x+2.6,y-5;x+2.6,y+5;x-2.6,y+5;x-2.6,y;x+2.6,y ! 8
CASE 9
PLOT LINES:x+2.6,y;x-2.6,y;x-2.6,y-5;x+2.6,y-5;x+2.6,y+5;x-2.6,y+5 ! 9
CASE 10
LET x=x-7
PLOT LINES:x+2.6,y-5;x+2.6,y+5 ! 1
LET x=x+11
PLOT LINES:x-2.6,y+5;x-2.6,y-5;x+2.6,y-5;x+2.6,y+5;x-2.6,y+5 ! 0
CASE 11
LET x=x-5
PLOT LINES:x+2.6,y-5;x+2.6,y+5 ! 1
LET x=x+9
PLOT LINES:x+2.6,y-5;x+2.6,y+5 ! 1
CASE 12
LET x=x-7
PLOT LINES:x+2.6,y-5;x+2.6,y+5 ! 1
LET x=x+11
PLOT LINES:x-2.6,y-5;x+2.6,y-5;x+2.6,y;x-2.6,y;x-2.6,y+5;x+2.6,y+5 ! 2
CASE ELSE
END SELECT
END SUB
SECOND¤µ¤ó¤Î¥×¥í¥°¥é¥à¤Î£³¹ÔÌܤÎSET WINDOWʸ¤Î¸å¤í¤Ë¤Ä¤®¤Î¥×¥í¥°¥í¥à¤òÁÞÆþ¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£´û¸¤ÎSUB linefont¤ÏÇѤ·¤Æ¤¯¤À¤µ¤¤¡£
CenturyÂΤÏÆüËܸì¤ËÂбþ¤·¤Æ¤Ê¤¤¤Î¤Ç"±¦¥¯¥ê¥Ã¥¯¤ÇÄä»ß"¤ò"Right Click to Stop"¤Ë¤â¤É¤·¤Æ¤¯¤À¤µ¤¤¡£
MAT PLOTʸ¤Ï3¼¡¸µ¤ÎÇÛÎó¤Ë¤ÏŬ±þ¤·¤Æ¤Ê¤¤¤Î¤Ç¡¢¤¢¤Þ¤ê¥¹¥Þ¡¼¥È¤Ç¤Ï¤Ê¤¤¤Ç¤¹¤¬¤Ê¤ó¤È¤«1ÉðÊÆâ¤ËÉÁ²è¤Ç¤¤ë¤È»×¤¤¤Þ¤¹¡£ÃÙ¤ì¤ë¾ì¹ç¤Ïʸ»ú¥µ¥¤¥º(th=13)¤ò¾®¤µ¤¯¤·¤Æ¤ß¤Æ²¼¤µ¤¤¡£
!
ASK TEXT HEIGHT ath
ASK TEXT JUSTIFY atjx$,atjy$
SET POINT STYLE 1
SET TEXT JUSTIFY "CENTER","HALF"
LET th=13
SET TEXT HEIGHT th
SET TEXT FONT "Century" ,0
ASK TEXT WIDTH("WW") tw
ASK PIXEL SIZE (0,0;1.2*th,1.2*tw) px,py
LET p=ABS(px*py)
DIM f0(p,2),f1(p,2),f2(p,2),f3(p,2),f4(p,2),f5(p,2),f6(p,2),f7(p,2),f8(p,2),f9(p,2),f10(p,2),f11(p,2),f12(p,2)
LET pitchx=WORLDX(PIXELX(0)+1)
LET pitchy=WORLDY(PIXELY(0)+1)
FOR i=1 TO 12
PLOT TEXT ,AT 0,0 : STR$(i)
MAT f0=ZER
LET k=0
FOR x=-0.6*tw TO 0.6*tw STEP pitchx
FOR y=0.6*th TO -0.6*th STEP pitchy
ASK PIXEL VALUE (x,y) pc
IF pc=1 THEN ! Ãæ´Ö¿§(³¥¿§)¤òÆɤ߹þ¤à¤Ê¤é¾ò·ï¤ò pc<>0
LET k=k+1
LET f0(k,1)=x
LET f0(k,2)=y
END IF
NEXT y
NEXT x
CALL font_read
CLEAR
NEXT i
SET TEXT HEIGHT ath
SET TEXT JUSTIFY atjx$,atjy$
!
SUB font_read
MAT f12=ZER(k,2)
FOR j=1 TO k
LET f12(j,1)=f0(j,1)
LET f12(j,2)=f0(j,2)
NEXT j
SELECT CASE i
CASE 1
MAT f1=f12
CASE 2
MAT f2=f12
CASE 3
MAT f3=f12
CASE 4
MAT f4=f12
CASE 5
MAT f5=f12
CASE 6
MAT f6=f12
CASE 7
MAT f7=f12
CASE 8
MAT f8=f12
CASE 9
MAT f9=f12
CASE 10
MAT f10=f12
CASE 11
MAT f11=f12
CASE ELSE
END SELECT
END SUB
SUB linefont(fi,x,y)
SELECT CASE fi
CASE 1
DRAW numplot(f1) WITH SHIFT(x,y)
CASE 2
DRAW numplot(f2) WITH SHIFT(x,y)
CASE 3
DRAW numplot(f3) WITH SHIFT(x,y)
CASE 4
DRAW numplot(f4) WITH SHIFT(x,y)
CASE 5
DRAW numplot(f5) WITH SHIFT(x,y)
CASE 6
DRAW numplot(f6) WITH SHIFT(x,y)
CASE 7
DRAW numplot(f7) WITH SHIFT(x,y)
CASE 8
DRAW numplot(f8) WITH SHIFT(x,y)
CASE 9
DRAW numplot(f9) WITH SHIFT(x,y)
CASE 10
DRAW numplot(f10) WITH SHIFT(x,y)
CASE 11
DRAW numplot(f11) WITH SHIFT(x,y)
CASE 12
DRAW numplot(f12) WITH SHIFT(x,y)
END SELECT
END SUB
PICTURE numplot(fm(,))
MAT PLOT POINTS : fm
END PICTURE
!
Á´³Ñʸ»ú22ʸ»ú¤«¤é¤Ê¤ëÊÑ¿ô̾¤Ç¤¹¡£(Ãí°Õ;´Ä¶°Í¸ʸ»ú¤â¤¢¤ê¤Þ¤¹)
10 LET ¤«¤££±£Â£ä¥µ¦²¦Â§¥§ñ¨ª±·ÊÖàßäåêó°¡=3
20 PRINT ¤«¤££±£Â£ä¥µ¦²¦Â§¥§ñ¨ª±·ÊÖàßäåêó°¡+5
30 END
FUNCTION fnCHECK(x,y) !¡¡Í½¸«¸¡ºº¡£
LET c=0
IF sp< Xw*Yw-1 THEN
LET fnCHECK=1 !¡¡µ¢¤ê¤Î°ú¿ô¡á£±
IF ABS(I_(1)-I_(0))=4 THEN EXIT FUNCTION !return(1)
FOR i=0 TO 7
IF E_(y+DY_(i),x+DX_(i))< 2 THEN
IF E_(y+DY_(i),x+DX_(i))=0 THEN EXIT FUNCTION !return(1)
LET c=c-1
END IF
NEXT i
IF c< -1 THEN
IF sp<>1 THEN EXIT FUNCTION !return(1)
END IF
FOR y=0 TO Yw-1
FOR x=0 TO Xw-1
IF E_(y,x)< 2 THEN
IF E_(y,x)=0 THEN EXIT FUNCTION !return(1)
LET c=c+1
IF c>1 THEN EXIT FUNCTION !return(1)
END IF
NEXT x
NEXT y
END IF
LET fnCHECK=0 !¡¡µ¢¤ê¤Î°ú¿ô¡á£°
END FUNCTION !return(0)
SUB PUTL(x,y,dx,dy,c)
SET LINE COLOR c
PLOT LINES: x,y; x+dx,y+dy
PLOT POINTS: x+dx,y+dy
END SUB
SUB DISP_E
PRINT
MAT PRINT USING REPEAT$(" ##",Xw+4) :E_
IF DF=1 THEN pause !¡¡//debug
END SUB
SUB FIN
!-----disp_A
SET AREA COLOR 0
PLOT AREA :0,0; Xw-1,0; Xw-1,Yw-1; 0,Yw-1
LET x=0
LET y=0
CALL PUTL(x,y,0,0,2)
FOR s=0 TO Xw*Yw-1
CALL PUTL(x,y,DX_(I_(s)),DY_(I_(s)),2)
LET x=x+DX_(I_(s))
LET y=y+DY_(I_(s))
NEXT s
!-----disp cout--time
LET Count=Count+1
LET t1=INT(TIME-t0)
IF t1< 0 THEN LET t1=t1+86400
PLOT TEXT,AT Xct,Yct :"count= "& STR$(Count)& " ----- "&
&& USING$("%%",MOD(INT(t1/3600),24))& ":"&
&& USING$("%%",MOD(INT(t1/60),60))& ":"& USING$("%%",MOD(t1,60))
IF DF=2 THEN pause !¡¡//debug
END SUB
DIM A(100),B(100),C(100)
LET m=3
LET n=8
MAT A=ZER(m)
MAT B=ZER(m*n)
MAT C=ZER(m TO n)
¤È¤³¤í¤¬MATʸ¤Ç¤Ïź»ú¤Î²¼¸Â¤òÊѹ¹¤¹¤ë¤³¤È¤Ï¤Ç¤¤Ê¤¤¤¿¤á¡¢C¤Î²¼¸Â¤Ï1,¾å¸Â¤Ï6(=n-m+1)¤Ë¤Ê¤ê¤Þ¤¹¡£
¥Ø¥ë¥×¤Ç¤Ï¡Øź»ú¤Î²¼¸Â¤òÊѤ¨¤¿¤¤¤È¤¤Ï¡¤MAT READʸ¤«¡¤³ÈÄ¥µ¡Ç½¤ÎMAT REDIMʸ¤òÍѤ¤¤ë¡£¡Ù¤È¤¢¤ê¤Þ¤¹¡£
MAT READ C(m TO n) ¤È¤¹¤ì¤Ð¤è¤¤¤ï¤±¤Ç¤¹¤¬¡¢DATAʸ¤òÆɤޤ»¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
MAT REDIM C(m TO n) ¤Ê¤é¤ÐÇÛÎóÍ×ÁǤϤ½¤Î¤Þ¤Þ¤Çź»ú¤Î²¼¸Â¤òÊѹ¹¤Ç¤¤Þ¤¹¤¬JISµ¬³Ê³°¤Ç¤¹¡£
DECLARE EXTERNAL SUB redim
DIM A(100)
LET m=3
LET n=8
CALL redim(A,m,n) ! MAT REDIM A(m TO n)¤ÈƱµÁ
PRINT LBOUND(A),UBOUND(A)
END
!
EXTERNAL SUB redim(p(),m,n) !ÇÛÎó¤Îź»ú¤Î¾å²¼¸Â¤òºÆÄêµÁ
WHEN EXCEPTION IN
DIM q(10000)
MAT q=p
MAT READ p(m TO n)
DATA 0
USE
END WHEN
FOR i=m TO n
LET p(i)=q(LBOUND(q)+i-m)
NEXT i
END SUB
!-----
LET g= 9.8 ! m/s^2¡¡½ÅÎϲîÅÙ
LET m1=.188 ! kg¡¡¤ª¤â¤ê
LET m2=.188 ! kg
LET L1= 5 !¡¡m¡¡ÄߤêËÀ
LET L2= 5 !¡¡m
LET r1=.75*SQR(m1) !¡¡¤ª¤â¤ê¤ÎÉÁ²è·Â
LET r2=.75*SQR(m2)
!
LET dt=0.05 !sec. ±é»»¥Ô¥Ã¥Á¡£¹â®µ¡ ¤Û¤É¡¢¾®¤µ¤¯¡£(0.05¤Ï¡¢Pentium3 500MHz)
!
!¢¨0.01¤¯¤é¤¤¤¬Ë¾¤Þ¤·¤¤¤¬¡¢ÉÁ²è¥Ô¥Ã¥Á(²èÌ̤Ëɽ¼¨)¤¬¡¢¤Ä¤¤¤ÆÍè¤ì¤Ê¤¯¤Ê¤Ã¤¿¤éÌ᤹¡£
!¡¡£²¤Ä¤Î¥Ô¥Ã¥Á¤¬¡¢¥º¥ì¤Æ¤¤¤ë¤ÈʪÍýŪ¤Ê®Å٤ǤϤʤ¯¤Ê¤ë¡£
!
!------------ £²½Å¿¶¤ê»Ò¤ÎÊýÄø¼°
! d(d¦È1)/dt^2=
! [ g*{sin¦È2*cos¦¤-¦Ì*sin¦È1}-{L2*(¦È2/dt)^2+L1*(¦È1/dt)^2*cos¦¤}*sin¦¤]
!¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡/[ L1*{¦Ì-cos¦¤^2}]
! d(d¦È2)/dt^2=
! [ g*¦Ì*{sin¦È1*cos¦¤-sin¦È2}+{¦Ì*L1*(¦È1/dt)^2+L2*(¦È2/dt)^2*cos¦¤}*sin¦¤]
!¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡/[ L2*{¦Ì-cos¦¤^2}]
!
! g= ½ÅÎϲîÅÙ¡¡¦Ì=(m1+m2)/m2¡¡¦¤=¦È1-¦È2
!
!---------- ¼°¤ÎÀ°Íý¡Ê¦È1¦È2 ¶¦¤Ë¡¢½ÅÎÏÊý¸þ£°¤«¤é¤Îº¸²ó¤ê³Ñ¡Ë
LET ¦Ì2=m2/(m1+m2)
LET L21=L2/L1
!
!ss1=-g/L1*sin¦È1 -¦Ì2*L21*¦Ø2^2*sin¦¤
!ss2=-g/L2*sin¦È2 +¡¡¡¡¡¡¡¡¦Ø1^2*sin¦¤/L21
!D=1-¦Ì2*COS¦¤^2
!d(¦È1)/dt=¦Ø1
!d(¦È2)/dt=¦Ø2
!d(¦Ø1)/dt=[¡¡¡¡¡¡¡¡¡¡¡¡ss1 - L21*¦Ì2*cos¦¤*ss2 ] /D
!d(¦Ø2)/dt=[ -cos¦¤/L21*ss1 + ¡¡¡¡¡¡¡¡¡¡¡¡¡¡ss2 ] /D
!
!---------- ÈùʬÊýÄø¼°¤Î¤Þ¤Þ¡¢¥ë¥ó¥²¡¦¥¯¥Ã¥¿Ë¡¤ÇÉÁ²è¡£
LET ¦È1=PI*0.8 ! ½é´ü³ÑÅÙ
LET ¦È2=PI*0.8
LET w1=0 !¡¡½é´ü³Ñ®ÅÙ
LET w2=0
!
DEF ss1(w2,¦È1,¦È2)=-g/L1*SIN(¦È1) -¦Ì2*L21*w2^2*SIN(¦È1-¦È2)
DEF ss2(w1,¦È1,¦È2)=-g/L2*SIN(¦È2) + w1^2*SIN(¦È1-¦È2)/L21
DEF D(¦È1,¦È2)=1-¦Ì2*COS(¦È1-¦È2)^2
!
DEF ¦Á1(w1,w2,¦È1,¦È2)=( ss1(w2,¦È1,¦È2) -L21*¦Ì2*COS(¦È1-¦È2)*ss2(w1,¦È1,¦È2) )/D(¦È1,¦È2)
DEF ¦Á2(w1,w2,¦È1,¦È2)=(-ss1(w2,¦È1,¦È2)*COS(¦È1-¦È2)/L21 +ss2(w1,¦È1,¦È2) )/D(¦È1,¦È2)
SUB RungeKutta
LET w11=w1
LET w12=w2
LET ¦Á11=¦Á1(w1,w2,¦È1,¦È2)
LET ¦Á12=¦Á2(w1,w2,¦È1,¦È2)
!
LET w21=w1+¦Á11*dt/2
LET w22=w2+¦Á12*dt/2
LET ¦Á21=¦Á1(w21,w22,¦È1+w11*dt/2,¦È2+w12*dt/2)
LET ¦Á22=¦Á2(w21,w22,¦È1+w11*dt/2,¦È2+w12*dt/2)
!
LET w31=w1+¦Á21*dt/2
LET w32=w2+¦Á22*dt/2
LET ¦Á31=¦Á1(w31,w32,¦È1+w21*dt/2,¦È2+w22*dt/2)
LET ¦Á32=¦Á2(w31,w32,¦È1+w21*dt/2,¦È2+w22*dt/2)
!
LET w41=w1+¦Á31*dt
LET w42=w2+¦Á32*dt
LET ¦Á41=¦Á1(w41,w42,¦È1+w31*dt,¦È2+w32*dt)
LET ¦Á42=¦Á2(w41,w42,¦È1+w31*dt,¦È2+w32*dt)
!
LET ¦È1=¦È1+(w11+2*w21+2*w31+w41)*dt/6
LET ¦È2=¦È2+(w12+2*w22+2*w32+w42)*dt/6
LET w1=w1+(¦Á11+2*¦Á21+2*¦Á31+¦Á41)*dt/6
LET w2=w2+(¦Á12+2*¦Á22+2*¦Á32+¦Á42)*dt/6
END SUB
!----¥¨¥Í¥ë¥®¡¼¡¦¥á¡¼¥¿¡¼
DEF ep1=m1*g*(L1-L1*COS(¦È1)) !°ÌÃÖ£±
DEF em1=(L1*w1)^2*m1/2 !±¿Æ°£±
DEF ep2=m2*g*( (L1-L1*COS(¦È1)+L2)-L2*COS(¦È2) ) !°ÌÃÖ£²
DEF em2=( (L1*w1)^2+(L2*w2)^2-2*L1*w1*L2*w2*COS(PI+¦È1-¦È2) )*m2/2 !±¿Æ°£²
!
!----run
LET w=13
SET WINDOW -w,w,-w,w
SET COLOR MIX(15) .5,.5,.5
SET TEXT background "OPAQUE"
LET t0=TIME
DO
LET t=TIME
IF dt=<ABS(t-t0) THEN
SET DRAW mode hidden
CLEAR
DRAW grid(5,5)
PLOT TEXT,AT -w*0.92,w*0.9:"¤ª¤â¤ê¤Î¥¨¥Í¥ë¥®¡¼[J]"
PLOT TEXT,AT -w*0.92,w*0.83:"°ÌÃÖ£±¡¡±¿Æ°£±¡¡ °ÌÃÖ£²¡¡±¿Æ°£²"
PLOT TEXT,AT -w*0.96,w*0.76,USING"##.#### ##.####¡¡##.#### ##.####":ep1,em1,ep2,em2
PLOT TEXT,AT -w*0.86,w*0.69,USING"##.####¡¡¡¡¡¡¡¡¡¡##.####":ep1+em1,ep2+em2
PLOT TEXT,AT -w*0.62,w*0.62,USING"##.####":ep1+em1+ep2+em2
PLOT TEXT,AT w*0.25,w*0.9:"¥Þ¥¦¥¹ ±¦¥Ü¥¿¥ó¤Ç¡¢½ªÎ»¡£"
PLOT TEXT,AT w*0.4,w*0.76,USING"±é»»¥Ô¥Ã¥Á=#.### ÉÃ":dt
PLOT TEXT,AT w*0.4,w*0.69,USING"ÉÁ²è¥Ô¥Ã¥Á=#.### ÉÃ":t-t0
LET t0=t
DRAW Pendulum0 WITH ROTATE(¦È1)
CALL RungeKutta !¡¡¼¡¤Î¦È1,¦È2 ¤Ø¹¹¿·
SET DRAW mode explicit
!stop
END IF
WAIT DELAY 0 !¡¡¾ÊÅÅÎϸú²Ì
MOUSE POLL mx,my,mlb,mrb
LOOP UNTIL mrb=1
PICTURE Pendulum0
DRAW circle WITH SCALE(0.2)
DRAW Pendulum1(L1,r1,"1")
DRAW Pendulum1(L2,r2,"2") WITH ROTATE(¦È2-¦È1)*SHIFT(0,-L1)
END PICTURE
PICTURE Pendulum1(L,r,w$)
PLOT LINES: 0,0;0,-L
DRAW disk WITH SCALE(r)*SHIFT(0,-L)
PLOT TEXT,AT r, r-L:w$
END PICTURE
RANDOMIZE
LET N=6 !¥³¥¤¥ó¤òÅꤲ¤ë²ó¿ô
DIM s(-N TO N) !ÅÀx¤ËÌá¤ë²ó¿ô
MAT s=ZER
LET iter=50000 !»î¹Ô²ó¿ô
FOR i=1 TO iter
LET x=0 !¸¶ÅÀ
FOR k=1 TO N !¥³¥¤¥ó¤òÅꤲ¤ë
IF RND<0.5 THEN LET x=x+1 ELSE LET x=x-1 !ɽ¤Ê¤é¡Ü£±¡¢Î¢¤Ê¤é¡Ý£±
NEXT k
LET s(x)=s(x)+1 !·ë²Ì
NEXT i
FOR i=-N TO N !ÅÀx¤ËÌá¤ë³ÎΨ
PRINT i;s(i)/iter
NEXT i
PRINT
FOR i=-N TO N !¾ì¹ç¤Î¿ô
PRINT USING "###: ###.##": i,s(i)/s(N) !x=N¤ò£±¤È¤¹¤ë
NEXT i
END
!¥Ñ¥¹¥«¥ë¤Î»°³Ñ·Á
LET N=10 !¥³¥¤¥ó¤òÅꤲ¤ë²ó¿ô
LET a=1 !¥Ñ¥¹¥«¥ë¤Î»°³Ñ·Á
LET b=0
LET c=1
DIM P(-N TO N) !¿ôľÀþ¾å¤Î³ÆÅÀ
MAT P=ZER
LET P(0)=1 !¸¶ÅÀ¤Ë°ÌÃÖÉÕ¤±¤ë
FOR i=-N TO N !ÌÜÀ¹¤ê
PRINT USING " ####": i;
NEXT i
PRINT
FOR i=-N TO N !¿ôľÀþ
PRINT "----+";
NEXT i
PRINT
FOR i=0 TO N !»ØÄê²ó¿ô
MAT PRINT USING(REPEAT$(" ####",2*N+1)): P; !¸½¾õ
PRINT USING " ### ²ó¤Î¾ì¹ç": i
LET T1=0 !º¸¡¡¢¨º¸Ã¼
LET T2=P(-N) !Ãæ±û
FOR x=-N TO N !º¸¤«¤é±¦¤ØÁöºº¤¹¤ë
IF x+1>N THEN LET T3=0 ELSE LET T3=P(x+1) !±¦
LET P(x)=a*T1+b*T2+c*T3
LET T1=T2 !¼¡¤Ø
LET T2=T3
NEXT x
NEXT i
END
!
! °ì¸Ä¤Î¿À·ÐºÙ˦(neuro)
! ¤½¤Î ¥«¥ª¥¹(chaos)¤ò¡¢Ãµ¤·¡¢¸«¤ë¡¢¥Ä¡¼¥ë
!
!----------------------------
!¡¡"Neuro12"
!
!¡¡2009.1.18
!----------------------------
OPTION ARITHMETIC NATIVE
OPTION BASE 0
SET TEXT background "OPAQUE"
SET POINT STYLE 1
SET AREA COLOR 0
LET DLY=50
DIM St(1,DLY) ,Sy(2000), B4(0,500)
!
LET Kr=0.5
LET Af=1
LET Ei=-70
LET Ss=0.31 !¡¡Ss=(Kr-1)(theta-s(t))¡¡¡Äs(t)=0
LET theta=Ss/(Kr-1)
DEF Ri(Yi,Ss)=Kr*Yi-Af/(1+EXP(Ei*Yi))+Ss
PLOT TEXT,AT .04,.96:"*** Neuro Cell"
PLOT TEXT,AT .04,.92:"Right Click to Stop"
PLOT TEXT,AT .04,.89:"Left Click & Drag '|' Line"
!
!-----
LET Y0=Af/100
LET Af2=Af
DO
LET Af=Af2
CALL ma200_
! ma100_
!----- clear
SET WINDOW -Af*2.07-Af*1.06,Af*2.07-Af*1.06,-Af*2.07-Af*1.05,Af*2.07-Af*1.05
PLOT AREA: -Af,-Af;Af,-Af;Af,Af;-Af,Af
!----- box outline
SET LINE COLOR "blue"
PLOT LINES: -Af,-Af; Af,-Af; Af,Af; -Af,Af; -Af,-Af
!-----
PLOT TEXT,AT Af*.03,Af*.85: "+Af Y(t+1)"
PLOT TEXT,AT -Af*.97,Af*0.13: "Y(t)"
PLOT TEXT,AT -Af*.97, 0: "-Af"
PLOT TEXT,AT Af*.8, 0: "+Af"
PLOT TEXT,AT Af*.03,-Af*.98: "-Af"
!----- Sy(w)=Y(t)
LET imax=pixelx(Af)-pixelx(-Af)
LET dA1=(Af+Af)/imax
FOR i=0 TO imax
LET Sy(i)=Ri(-Af+i*dA1, Ss)
NEXT i
!-----
DO
LET Y1=Ri(Y0,Ss)
!----- erase old signal
LET W0=St(0,t)
LET W1=St(1,t)
FOR i=0 TO DLY-1
IF W0=St(0,i) AND W1=St(1,i) AND t<>i THEN EXIT FOR
NEXT i
IF DLY=i THEN
SET LINE COLOR 0
PLOT LINES: W0,W0; W0,W1;
PLOT LINES: W1,W1
END IF
!----- axis
SET LINE COLOR "cyan" ! axis_Y(t)¡Ä ¡½
PLOT LINES: -Af,0; Af,0
SET LINE COLOR "magenta" ! axis_Y(t+1)¡Ä¡Ã
PLOT LINES: 0,-Af; 0,Af
!----- draw curve Y(t)
SET LINE COLOR 1
FOR i=0 TO imax
PLOT LINES: -Af+i*dA1, Sy(i);
NEXT i
PLOT LINES
!----- signal
SET LINE COLOR "cyan" ! input_Y(t)¡Ä¡Ã
PLOT LINES: Y0,Y0; Y0,Y1;
SET LINE COLOR "magenta" ! output_Y(t+1)¡Ä ¡½
PLOT LINES: Y1,Y1
!-----
LET St(0,t)=Y0
LET St(1,t)=Y1
LET t=MOD(t+1,DLY)
LET Y0=Y1
!-----
WAIT DELAY .02
MOUSE POLL x,y,mlb,mrb
LOOP UNTIL mlb=1 OR mrb=1
!
!----- cursor input
IF mlb=1 THEN
SET WINDOW -0.1*Af,Af, -Af*2.1+Af*1.08,Af*2.1+Af*1.08
DO
MOUSE POLL x,y,mlb,mrb
IF 0<=x AND x<=Af THEN
IF y< Af THEN
IF bx4<>pixelx(x) THEN
LET Ss=x
LET theta=Ss/(Kr-1)
CALL
cursor4( bx4,B4)
END IF
ELSEIF x< Af*.43 THEN
IF y< Af*1.4 THEN
ELSEIF y< Af*1.7 THEN
IF
bx3<>pixelx(x) THEN
LET Ei=x*120/(Af*.43)-120
CALL cursor13( bx3, 1.7, 1.4)
END IF
ELSEIF y< Af*2.1 THEN
IF
bx2<>pixelx(x) THEN
LET Kr=x*1/(Af*.43)
LET theta=Ss/(Kr-1)
CALL cursor13( bx2, 2.1, 1.8)
END IF
ELSEIF y< Af*2.5 THEN
IF
bx1<>pixelx(x) THEN
LET Af2=x*2/(Af*.43)+0.5
MAT St=ZER
LET Y0=Af/100
CALL cursor13( bx1, 2.5, 2.2)
END IF
END IF
END IF
END IF
WAIT DELAY .05
LOOP UNTIL mlb=0
END IF
LOOP UNTIL mrb=1
SUB cursor4( bx,B(,))
MAT PLOT CELLS, IN worldx(bx),Af; worldx(bx),-Af: B
LET bx=pixelx(x)
ASK PIXEL ARRAY (x,Af) B
SET LINE COLOR "red"
PLOT LINES: x,-Af; x,Af
PLOT TEXT,AT 0,Af,USING "Kr=#.### :Af=#.### :Ei=####.# :Ss=#.### :theta=####.###": Kr, Af, Ei, Ss, theta
END SUB
SUB cursor13( bx, uy,ly)
SET LINE COLOR 0
PLOT LINES: worldx(bx),Af*uy-dAy; worldx(bx),Af*ly+dAy
LET bx=pixelx(x)
SET LINE COLOR "red"
PLOT LINES: x,Af*uy-dAy; x,Af*ly+dAy
PLOT TEXT,AT 0,Af,USING "Kr=#.### :Af=#.### :Ei=####.# :Ss=#.### :theta=####.###": Kr, Af2, Ei, Ss, theta
END SUB
SUB ma200_
!----- clear
SET WINDOW -0.1*Af,Af, -Af*2.1+Af*1.08,Af*2.1+Af*1.08
PLOT AREA: 0,-Af;Af,-Af;Af,Af;0,Af
!----- box outline
SET LINE COLOR "blue"
PLOT LINES: 0,-Af; Af,-Af; Af,Af; 0,Af; 0,-Af
PLOT LINES: 0,0; Af,0
!-----
PLOT TEXT,AT -.06*Af,.9*Af : "+Af"
PLOT TEXT,AT -.07*Af,-.05*Af : "Y(t)"
PLOT TEXT,AT -.06*Af,-Af : "-Af"
PLOT TEXT,AT Af*.5,-Af*.98: "0 <--- Ss ---> +Af"
!-----
LET dA2=Af/(pixelx(Af)-pixelx(0))
LET dAy=Af/(pixely(Af)-pixely(0))
LET Yt=0 ! Y(t)
FOR j=0 TO Af STEP dA2 ! j= Ss= (Kr-1)*theta
FOR i=0 TO 99
LET Yt=Ri(Yt,j)
PLOT POINTS: j,Yt
NEXT i
NEXT j
!----- setup cursor Ss
LET x=Ss
ASK PIXEL SIZE (x,Af;x,-Af) i,j
MAT B4=ZER(0,j-1)
ASK PIXEL ARRAY (x,Af) B4
LET bx4=pixelx(x)
CALL cursor4( bx4, B4)
!-----
LET x=(Ei+120)*Af*.43/120 !// Ei=x*120/(Af*.43)-120
LET bx3=pixelx(x)
CALL cursor130( bx3, 1.7, 1.4, "Ei")
LET x=Kr*Af*.43 !// Kr=x*1/(Af*.43)
LET bx2=pixelx(x)
CALL cursor130( bx2, 2.1, 1.8, "Kr")
LET x=(Af-0.5)*Af*.43/2 !// Af2=x*2/(Af*.43)+0.5
LET bx1=pixelx(x)
CALL cursor130( bx1, 2.5, 2.2, "Af")
END SUB
SUB cursor130( bx, uy, ly, w$)
PLOT TEXT,AT -.06*Af,Af*(uy-0.2): w$
SET LINE COLOR "blue"
PLOT LINES: 0,Af*uy; Af*.43,Af*uy; Af*.43,Af*ly; 0,Af*ly; 0,Af*uy
CALL cursor13( bx, uy, ly)
END SUB
!
!¡¡ÉºÎ®¤¹¤ë¥Ë¥å¡¼¥é¥ë¡¦¥Í¥Ã¥È¡Ê¹¹¿·¡ËºÆÅê¹Æ
!
!----
OPTION ARITHMETIC NATIVE
OPTION BASE 0
SET WINDOW -10,10, 20,0
SET TEXT background "OPAQUE"
!
DIM E(99),R(99),theta(99),F(99)
DIM Y(99),X(99),NetWork(99,99)
DIM P_(1 TO 5, 99),Px(99)
DIM Sum(1 TO 5)
MAT READ P_
! 1)
DATA 1,1,0,0,0,0,0,0,1,1
DATA 1,1,1,0,0,0,0,1,1,1
DATA 0,1,1,1,0,0,1,1,1,0
DATA 0,0,1,1,1,1,1,1,0,0
DATA 0,0,0,1,1,1,0,0,0,0
DATA 0,0,0,0,1,1,1,0,0,0
DATA 0,0,1,1,1,1,1,1,0,0
DATA 0,1,1,1,0,0,1,1,1,0
DATA 1,1,1,0,0,0,0,1,1,1
DATA 1,1,0,0,0,0,0,0,1,1
! 2)
DATA 0,0,0,0,0,1,0,0,0,0
DATA 0,0,0,0,1,1,1,0,0,0
DATA 0,0,0,0,1,1,1,0,0,0
DATA 0,0,0,1,1,1,1,1,0,0
DATA 0,0,0,1,1,0,1,1,0,0
DATA 0,0,1,1,1,0,1,1,1,0
DATA 0,0,1,1,0,0,0,1,1,0
DATA 0,1,1,1,0,0,0,1,1,1
DATA 0,1,1,1,1,1,1,1,1,1
DATA 0,1,1,1,1,1,1,1,1,1
! 3)
DATA 0,0,1,1,1,0,0,0,1,1
DATA 0,1,1,1,1,1,1,1,1,1
DATA 1,1,1,0,1,1,1,1,0,0
DATA 1,1,0,0,0,1,1,0,0,0
DATA 0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,1,1,0,0,0,1,1
DATA 0,0,1,1,1,1,0,1,1,1
DATA 1,1,1,1,1,1,1,1,1,0
DATA 1,1,0,0,0,1,1,1,0,0
DATA 0,0,0,0,0,0,0,0,0,0
! 4)
DATA 0,0,1,0,0,0,0,1,0,0
DATA 0,0,1,1,0,0,1,1,0,0
DATA 0,0,1,1,1,1,1,1,0,0
DATA 0,0,1,1,1,1,1,1,0,0
DATA 0,0,1,1,1,1,1,1,0,0
DATA 0,1,1,1,1,1,1,1,1,0
DATA 1,1,1,1,1,1,1,1,1,1
DATA 0,0,0,1,1,1,1,0,0,0
DATA 0,0,0,0,1,1,1,0,0,0
DATA 0,0,0,0,0,1,0,0,0,0
! 5)
DATA 0,0,0,0,1,1,0,0,0,0
DATA 0,1,1,0,1,1,0,1,1,0
DATA 0,1,0,0,1,1,0,0,1,0
DATA 0,0,0,0,1,1,0,0,0,0
DATA 1,1,1,1,1,1,1,1,1,1
DATA 1,1,1,1,1,1,1,1,1,1
DATA 0,0,0,0,1,1,0,0,0,0
DATA 0,1,1,0,1,1,0,1,1,0
DATA 0,1,1,0,1,1,0,1,1,0
DATA 0,0,0,0,1,1,0,0,0,0
!----- ³Æ¥Ë¥å¡¼¥í¥ó0~99 ¤Î¶îÆ°
SUB Xi00
FOR i=0 TO 99
LET w=0
FOR j=0 TO 99
LET w=w+NetWork(i,j)*X(j)
NEXT j
LET F(i)=Kf*F(i)+w
LET R(i)=Kr*(R(i)+theta(i))-Af*X(i)-theta(i)
LET Y(i)=R(i)+F(i)
NEXT i
FOR i=0 TO 99
IF Ei*Y(i)< 709 THEN !¡¡·å¤¢¤Õ¤ìËÉ»ß
LET X(i)=1/(1+EXP(Ei*Y(i)))
ELSE
LET X(i)=1/(1+EXP(709))
END IF
NEXT i
END SUB
!----- ³Æ¥Ë¥å¡¼¥í¥ó¤Î½ÐÎÏ X(0~99) ȯ²Ð¤Î¡¢²èÌÌɽ¼¨¡£
SUB DispX
SET DRAW mode hidden
SET AREA COLOR 0
PLOT AREA:-10,10; 0,10; 0,0; 10,0; 10,20;-10,20
SET AREA COLOR 2 !¡¡//fire
FOR V=0 TO 9
FOR H=0 TO 9
LET i=V*10+H
IF 0.5=< X(i) THEN
PLOT AREA: H,V; H+1,V; H+1,V+1; H,V+1
LET Px(i)=1
SET COLOR MIX(0) 0,1,1 ! B.G.color cyan( text)
ELSE
PLOT LINES: H,V; H,V+1; H+1,V+1
LET Px(i)=0
SET COLOR MIX(0) 1,1,1 ! B.G.color 0
END IF
!----- ¥Ë¥å¡¼¥í¥ó¤ÎÆâÉô(-~0~+) 0=< ¤Ïȯ²Ð
PLOT TEXT,AT H*2-10, V*0.8+12, USING"###.###":Y(i)
NEXT H
NEXT V
SET COLOR MIX(0) 1,1,1 ! B.G.color 0
SET DRAW mode explicit
END SUB
!----- À¸À®¥Ñ¥¿¡¼¥ó¤ÎʬÊÌ ·×¿ô¤Î¡¢²èÌÌɽ¼¨¡£
SUB Compare
FOR n_=1 TO 5
FOR i=0 TO 99
IF P_(n_,i)<>Px(i) THEN EXIT FOR
NEXT i
IF 99< i THEN
!¡¡----- °ìÃ×
LET PC_=10 !¡¡//timer ON 1st.to 2nd.Cursor
IF PB_=n_ THEN EXIT SUB
IF PN_>0 THEN PLOT
TEXT,AT -8, PN_+1.5: ":"& STR$(Sum(PN_))& " " !¡¡//old
1st.2nd.Cursor OFF
LET PB_=n_ !¡¡//flag 2nd.Cursor
LET PN_=n_ !¡¡//flag 1st.Cursor
LET Sum(n_)=Sum(n_)+1 !¡¡·×¿ô
SET COLOR MIX(0) 0,1,1 !¡¡//new 1st.Cursor ON (B.G.color)
PLOT label,AT -8, n_+1.5: ":"& STR$(Sum(n_))& " "
SET COLOR MIX(0) 1,1,1
beep
EXIT SUB
!-----
END IF
NEXT n_
!¡¡----- ÉÔ°ìÃ×
IF PB_=0 THEN EXIT SUB
IF PC_>1 THEN
LET PC_=PC_-1
EXIT SUB
END IF
SET COLOR MIX(0) .75,.75,.75 !¡¡//new 2nd.Cursor ON (B.G.color)
PLOT TEXT,AT -8, PB_+1.5: ":"& STR$(Sum(PB_))& " "
SET COLOR MIX(0) 1,1,1
LET PB_=0
END SUB
100 INPUT PROMPT "p=": P
110 INPUT PROMPT "q=": Q
120 INPUT PROMPT "d=": D
130 LET U=0
140 FOR K=1 TO D !d°Ê²¼¤Î¼«Á³¿ôk¤Î¤¦¤Á¤Ç
150 IF K-INT(K/P)*P=0 THEN GOTO 210 !k¤¬p¤ÎÇÜ¿ô¤Î¾ì¹ç¡Êk=m*p+0¡Ë¡¡¢¨MOD(K,P)=0
160 FOR M=0 TO INT(K/P) !£°¤«¤éP¤Ç³ä¤Ã¤¿¾¦¤Þ¤Ç¡¡¢èk=m*p+r
170 LET R=K-M*P !k-m*p=n*q
180 IF R-INT(R/Q)*Q=0 THEN GOTO 210 !r¤¬q¤ÎÇÜ¿ô¤Î¾ì¹ç¡¡¢¨MOD(R,Q)=0
190 NEXT M
200 GOTO 230 !³ºÅö¤Ê¤·¡£¼¡¤Ø
210 PRINT K !¾ò·ï¤òËþ¤¿¤¹
220 LET U=U+1
230 NEXT K
240 PRINT "Áí¿ô="; U
250 END
100 INPUT PROMPT "p=": P
110 INPUT PROMPT "q=": Q
120 INPUT PROMPT "d=": D
130 LET U=0
140 FOR K=1 TO D !d°Ê²¼¤Î¼«Á³¿ôk¤Î¤¦¤Á¤Ç
150 !
160 FOR M=0 TO INT(K/P) !£°¤«¤éK¤òP¤Ç³ä¤Ã¤¿¾¦¤Þ¤Ç
170 LET R=K-M*P !k-m*p=n*q
180 IF R-INT(R/Q)*Q=0 THEN GOTO 210 !r¤¬q¤ÎÇÜ¿ô¤Î¾ì¹ç¡¡¢¨MOD(R,Q)=0
190 NEXT M
200 GOTO 230 !³ºÅö¤Ê¤·¡£¼¡¤Ø
210 PRINT K; M;INT(R/Q) !¾ò·ï¤òËþ¤¿¤¹M,N¡¡¢¨
220 LET U=U+1
230 NEXT K
240 PRINT "Áí¿ô="; U
250 END
¡ö¥¢¥ë¥´¥ê¥º¥à¤Î¿ô³ØŪÇØ·Ê
ÉÔÄêÊýÄø¼° k=m*p+n*q ¤Ï¡¢k-m*p=n*q ¤ÈÊÑ·Á¤µ¤ì¤ë¡£
¹çƱ¼°¤Çɽ¤¹¤È¡¢k-m*p¢á0 mod q ¤È¤Ê¤ë¡£
m ¤Ï£°°Ê¾å¤ÎÀ°¿ô¡¢p ¤Ï¼«Á³¿ô¤è¤ê¡¢m*p¡æ0 ¤È¤Ê¤ë¡£¡¡Æ±Íͤˡ¢n*q¡æ0¡£
¤Þ¤¿¡¢n*q=k-m*p¡æ0 ¤è¤ê¡¢k¡æm*p ¤È¤Ê¤ë¡£
¤·¤¿¤¬¤Ã¤Æ²ò¤¬¤¢¤ì¤Ð¡¢m¤Ï0¡ÁINT(K/P)¤Ç¸«¤Ä¤«¤ë¡£
100 INPUT PROMPT "p=": P
110 INPUT PROMPT "q=": Q
120 INPUT PROMPT "d=": D
130 LET U=0
140 FOR K=1 TO D !d°Ê²¼¤Î¼«Á³¿ôk¤Î¤¦¤Á¤Ç
150 !
160 FOR M=0 TO INT(K/P) !£°¤«¤éK¤òP¤Ç³ä¤Ã¤¿¾¦¤Þ¤Ç
170 LET R=K-M*P !k-m*p=n*q
180 IF R-INT(R/Q)*Q=0 THEN !r¤¬q¤ÎÇÜ¿ô¤Î¾ì¹ç¡¡¢¨MOD(R,Q)=0
PRINT K; M;INT(R/Q) !¾ò·ï¤òËþ¤¿¤¹M,N
LET U=U+1
END IF
190 NEXT M
200 !
210 !
220 !
230 NEXT K
240 PRINT "Áí¿ô="; U !¢¨°ÕÌ£¤¬ÊѤï¤ë
250 END
º£Æü¤Ï
full basic ¤Ç¡¡¡¡Í¸ÂÍ×ÁÇË¡¤Î¡¡¹½Â¤²òÀÏ¥½¥Õ¥È¤ò¡¡¡¡³«È¯¤·¤Æ¤¤¤Þ¤¹
C++¡¡¤Ç¤â¡¡¤·¤Æ¤¤¤Þ¤¹¤¬
full basic ¤Ï¡¡¡¡¥°¥é¥Ò¥Ã¥¯¤¬¡¡¡¡´Êñ¤Ç¡¡¡¡£ã++¡¡¤è¤ê¡¡¡¡ÊØÍø¤Ç¤¹
¤·¤«¤·
»þ´Ö¤¬¡¡¡¡¤«¤«¤ê¤Þ¤¹
²òÀϲÄǽÍ×ÁÇ¿ô¤Ï
£³GRAM¡¡¡¡¤Ç
full basic £¶£°£°£°¡¡Í×ÁÇ
C++¡¡¡¡¡¡¡¡¡¡£±£²£°£°£°¡¡Í×ÁǤǤ¹
Full BASIC¤Î¾ì¹ç¡¢¹ÔÎ󤬷׻»¤Ç¤¤ë¤Î¤Ç¡¢Â¾¤Î¸À¸ì¤è¤ê¤Ï´Êñ¤Ë·×»»¤Ç¤¤ë¤È»×¤¤¤Þ¤¹¡£
¤¿¤À¡¢£²¹à±é»»¤Þ¤Ç¤Ç¤¹¤«¤é¡¢Å¸³«¤·¤Ê¤¬¤é¤³¤Ä¤³¤Ä·×»»¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
REM ***¡¡µÕ¹ÔÎó¤Ç¹â®¥Þ¥¯¥í¡¼¥ê¥óŸ³«
DIM a(3,3),b(3,1),c(3,1),d(3,3)
DEF f(x)=EXP(x)
LET x=0.0001
LET a(1,1)=x
LET a(1,2)=x^2
LET a(1,3)=x^3
LET a(2,1)=2*x
LET a(2,2)=4*x^2
LET a(2,3)=8*x^3
LET a(3,1)=3*x
LET a(3,2)=9*x^2
LET a(3,3)=27*x^3
MAT d=INV(a)
LET e=f(0)
LET c(1,1)=f(x)-e
LET c(2,1)=f(2*x)-e
LET c(3,1)=f(3*x)-e
MAT b=d*c
PRINT b(1,1)
PRINT b(2,1)
PRINT b(3,1)
END
2710 IF Na>0 THEN !¥¢¥ó¥×¤¬¤¢¤ì¤Ð
2720 FOR iter=1 TO 1 !°ÂÄꤵ¤»¤ë¡¡¢¨Í×Ä´À°¡¡¡¡<---------- ¤³¤³
2730 FOR i=1 TO Na
2740 LET b(AmpOut(i))=AmpK(i)*x(AmpPlus(i)) !Vo=K*V+¡¡¢¨ÆþÎϤò½ÐÎϤËÈ¿±Ç¤µ¤»¤ë
2750 NEXT i
2760 MAT x=Ai*b
2770 NEXT iter
2780 END IF
10 OPTION ARITHMETIC COMPLEX
LET j=SQR(-1)
OPTION BASE 1
OPTION ANGLE DEGREES
DIM FREQ(100,5)
LET FREQ(1,1)=10
LET FREQ(2,1)=12.25
LET FREQ(3,1)=15
LET FREQ(4,1)=17.32
LET FREQ(5,1)=20
LET FREQ(6,1)=24.5
LET FREQ(7,1)=30
LET FREQ(8,1)=34.6
LET FREQ(9,1)=40
LET FREQ(10,1)=50
LET FREQ(11,1)=60
LET FREQ(12,1)=70
LET FREQ(13,1)=80
LET FREQ(14,1)=90
FOR I=1 TO 14
LET P=I
LET FREQ(I,1)=FREQ(P,1)
NEXT I
FOR I=15 TO 28
LET P=I-14
LET FREQ(I,1)=FREQ(P,1)*10
NEXT I
FOR I=29 TO 42
LET P=I-28
LET FREQ(I,1)=FREQ(P,1)*100
NEXT I
FOR I=43 TO 56
LET P=I-42
LET FREQ(I,1)=FREQ(P,1)*1000
NEXT I
LET FREQ(57,1)=100000
! FOR I=1 TO 57
! PRINT "FREQ(";I;",1)=";FREQ(I,1)
! NEXT I
FOR K=0.9875 TO 1.0125 STEP 0.0125 !K¤ÏAMP¤Î¥²¥¤¥ó¡£
FOR P=1 TO 57
LET FF=FREQ(P,1)
LET ¦Ø=(2*PI*FF)
LET
A(1,1)=(1/Rs)+(1/R1)
!¡¡Ã¼»Ò¤Î¥¢¥É¥ß¥¿¥ó¥¹¤Î¹ç·×
LET
A(1,2)=-(1/R1)
!¡¢Ã¼»Ò¤Î¥¢¥É¥ß¥¿¥ó¥¹¤Î -1
LET A(1,3)=0
LET A(1,4)=0
LET A(2,1)=-(1/R1)
LET A(2,2)=(1/R1)+(1/R2)+¦Ø*C1*j !¢¢Ã¼»Ò¤Î¥¢¥É¥ß¥¿¥ó¥¹¤Î¹ç·×
LET A(2,3)=-(1/R2)
LET A(2,4)=0
LET A(3,1)=0
LET A(3,2)=-(1/R2)
LET A(3,3)=(1/R2)+(1/R3)+¦Ø*C2*j !££Ã¼»Ò¤Î¥¢¥É¥ß¥¿¥ó¥¹¤Î¹ç·×
LET A(3,4)=-(1/R3)-K*¦Ø*C2*j !¤³¤³¤ËK¤ÎÃͤòÆþ¤ì V5=K*V4 ¤òÈ¿±Ç¡£
!¥ß¥ë¥Þ¥ó¤ÎÄêÍý¤òŬÍÑ¡£
LET A(4,1)=0
LET A(4,2)=0
LET
A(4,3)=-(1/R3) !A(3,4)¤È¤ÏÃͤ¬°Û¤Ê¤ë¡£
LET
A(4,4)=(1/R3)+¦Ø*C3*j
!¤¤Ã¼»Ò¤Î¥¢¥É¥ß¥¿¥ó¥¹¤Î¹ç·×
LET B(1,1)=10 ! ÅÅή¸»¤«¤é10A¤òή¤·¤Æ¤¤¤ë¡£¡Ã¼»Ò¤Ï1V¤Ë¤Ê¤ë¡£
LET B(2,1)=0 ! ¥¥ë¥Ò¥Û¥Ã¥Õ¤Îˡ§¤«¤é ¥¼¥í¤Ç¤¢¤ë¡£
LET B(3,1)=0 ! ¥¥ë¥Ò¥Û¥Ã¥Õ¤Îˡ§¤«¤é ¥¼¥í¤Ç¤¢¤ë¡£
LET B(4,1)=0 ! ¥¥ë¥Ò¥Û¥Ã¥Õ¤Îˡ§¤«¤é ¥¼¥í¤Ç¤¢¤ë¡£
MAT T=INV(A)
MAT EOUT=T*B
! PRINT "FF=";FF
! MAT PRINT EOUT
LET EE1=EOUT(1,1)
LET EE2=EOUT(2,1)
LET EE3=EOUT(3,1)
LET EE4=EOUT(4,1)
LET EE5=K*EOUT(4,1)
PRINT
LET FREQ(P,2)=20*LOG10(ABS(EE5))
! LET FREQ(P,3)=20*LOG10(ABS(EE3))
LET G5=(ATN(IM(EE5)/RE(EE5)))
IF FF>750 THEN LET G5=G5-180
IF G5>0 THEN LET G5=G5-180
LET FREQ(P,4)=G5
! LET G3=(ATN(IM(EE3)/RE(EE3)))
! IF FF>750 THEN LET G3=G3-180
! LET FREQ(P,5)=G3
NEXT P
PRINT "K=";K
PRINT "ÈÖ¹æ
¼þÇÈ
¿ô E5
E3
¦È5 ¦È3"
FOR I=1 TO 57
PRINT USING "###": I;
PRINT USING " ###,###.#" : FREQ(I,1);
PRINT USING " ####.### dB": FREQ(I,2);
PRINT USING " ####.### dB": FREQ(I,3);
PRINT USING " ####.### ÅÙ": FREQ(I,4);
PRINT USING " ####.### ÅÙ": FREQ(I,5)
NEXT I
!¤³¤³¤«¤é¤Ï¡¢»³ÃæÍͤΥ°¥é¥Õ¥×¥í¥°¥é¥à¤ò»²¾È¡£
SET WINDOW 0.5,5.5, -55,5 !ɽ¼¨Îΰè
DRAW
grid(1,5) !
º¸Ã¼¤ÎÌÜÀ¹¤ê
FOR f=1 TO 6 !£ø¼´¤¬ÂпôÌÜÀ¹ f=1 TO 5 ¤Ç100k ¤Þ¤ÇÌÜÀ¹¤ë¡£
SET COLOR 1 !£±¤Ï¹õ¿§
PLOT TEXT ,AT f-0.1,+0.15: mid$("10 100 1k 10k 100k ",4*(f-1)+1,4)
NEXT f
FOR f=1 TO 6 !y¼´¤¬Ä¾ÀþÌÜÀ¹¤ê
SET COLOR 1 !£±¤Ï¹õ¿§
PLOT TEXT ,AT 0.8,-10*(f-1)-2: mid$(" 0 -25 -50 -75 -100-125 ",4*(f-1)+1,4)
NEXT f
FOR I=1 TO 57 STEP 1 !¼þÇÈ¿ô[Hz]
SET COLOR 1
PLOT LINES:LOG10(FREQ(I,1)) ,FREQ(I,2)/2.5; !ÍøÆÀ[dB]
NEXT I
PLOT LINES
! FOR I=1 TO 57 STEP 1 !¼þÇÈ¿ô[Hz]
! SET COLOR 5 !5¤Ï¿å¿§
! PLOT LINES: LOG10(FREQ(I,1)) ,FREQ(I,3)/2; !ÍøÆÀ[dB]
! NEXT I
! PLOT LINES
FOR I=1 TO 57 STEP 1 !°ÌÁê³ÑÅÙ[ÅÙ]
SET COLOR 4 !4¤ÏÀÖ¿§
PLOT LINES:LOG10(FREQ(I,1)) ,0.125*FREQ(I,4); !³ÑÅÙ[ÅÙ]
NEXT I
PLOT LINES
! FOR I=1 TO 57 STEP 1 !°ÌÁê³ÑÅÙ[ÅÙ]
! SET COLOR 3 !3¤ÏÎп§
! PLOT LINES:LOG10(FREQ(I,1)) ,0.25*FREQ(I,5); !³ÑÅÙ[ÅÙ]
! NEXT I
! PLOT LINES
FOR f=1 TO 6 !y¼´¤¬Ä¾ÀþÌÜÀ¹¤ê
SET COLOR 4
PLOT TEXT ,AT 5.1,-10*(f-1)-2: mid$(" 0 -80 -160-240-320-400 ",4*(f-1)+1,4)
NEXT f
PRINT
NEXT K ! ¤³¤³¤Ç,ÍøÆÀ K¤òÊѲ½¤µ¤»¤ë¡£
!*******************************************************************
!100 LET FF=1000
! PRINT 1/R1
! PRINT 1/R2
! PRINT 1/R3
! PRINT Y1
! PRINT Y2
! PRINT Y3
! FOR I=1 TO NP ! ÇòÀÐÍͤθæ½õ¸À¤ò»²¾È¡£¥Þ¥È¥ê¥¯¥¹¤Î¥Á¥§¥Ã¥¯¤ò¤·¤¿¡£
! FOR J=1 TO NP
! LET Z=A(I,J)
! PRINT USING "(##.######### ":RE(Z);
! PRINT USING "##.#########) ":IM(Z);
! NEXT J
! PRINT
! NEXT I
!**********************************************************************
10 OPTION ARITHMETIC COMPLEX
LET j=SQR(-1)
OPTION BASE 1
OPTION ANGLE DEGREES
DIM FREQ(100,5)
LET FREQ(1,1)=10
LET FREQ(2,1)=12.25
LET FREQ(3,1)=15
LET FREQ(4,1)=17.32
LET FREQ(5,1)=20
LET FREQ(6,1)=24.5
LET FREQ(7,1)=30
LET FREQ(8,1)=34.6
LET FREQ(9,1)=40
LET FREQ(10,1)=50
LET FREQ(11,1)=60
LET FREQ(12,1)=70
LET FREQ(13,1)=80
LET FREQ(14,1)=90
FOR I=1 TO 14
LET P=I
LET FREQ(I,1)=FREQ(P,1)
NEXT I
FOR I=15 TO 28
LET P=I-14
LET FREQ(I,1)=FREQ(P,1)*10
NEXT I
FOR I=29 TO 42
LET P=I-28
LET FREQ(I,1)=FREQ(P,1)*100
NEXT I
FOR I=43 TO 56
LET P=I-42
LET FREQ(I,1)=FREQ(P,1)*1000
NEXT I
LET FREQ(57,1)=100000
! FOR I=1 TO 57
! PRINT "FREQ(";I;",1)=";FREQ(I,1)
! NEXT I
FOR K=0.9875 TO 1.0125 STEP 0.0125 !K¤ÏAMP¤Î¥²¥¤¥ó¡£
FOR P=1 TO 57
LET FF=FREQ(P,1)
LET ¦Ø=(2*PI*FF)
LET A(1,1)=(1/Rs)+(1/R1) !¡¡Ã¼»Ò¤Î¥¢¥É¥ß¥¿¥ó¥¹¤Î¹ç·×
LET
A(1,2)=-(1/R1)
!¡¢Ã¼»Ò¤Î¥¢¥É¥ß¥¿¥ó¥¹¤Î -1
LET A(1,3)=0
LET A(1,4)=0
LET A(1,5)=0
LET A(2,1)=-(1/R1)
LET A(2,2)=(1/R1)+(1/R2)+¦Ø*C1*j !¢¢Ã¼»Ò¤Î¥¢¥É¥ß¥¿¥ó¥¹¤Î¹ç·×
LET A(2,3)=-(1/R2)
LET A(2,4)=0
LET A(2,5)=0
LET A(3,1)=0
LET A(3,2)=-(1/R2)
LET A(3,3)=(1/R2)+(1/R3)+¦Ø*C2*j!££Ã¼»Ò¤Î¥¢¥É¥ß¥¿¥ó¥¹¤Î¹ç·×
LET A(3,4)=-(1/R3) !A(4,3)¤ÈÃͤ¬Æ±¤¸¤¯¤·ÂоιÔÎó¤Ë¤¹¤ë¡£
LET A(3,5)=-¦Ø*C2*j
LET A(4,1)=0
LET A(4,2)=0
LET A(4,3)=-(1/R3) !A(3,4)¤ÈÃͤ¬Æ±¤¸¤¯¤·ÂоιÔÎó¤Ë¤¹¤ë¡£
LET A(4,4)=(1/R3)+¦Ø*C3*j !¤¤Ã¼»Ò¤Î¥¢¥É¥ß¥¿¥ó¥¹¤Î¹ç·×
LET A(4,5)=0
LET A(5,1)=0
LET A(5,2)=0
LET A(5,3)=0
LET A(5,4)=-K ! ¤³¤³¤ËK¤ÎÃͤòÆþ¤ì V5=K*V4 ¤òÈ¿±Ç¡£
LET A(5,5)=1 ! ¤³¤³¤Ë1¤ÎÃͤòÆþ¤ì V5=K*V4 ¤òÈ¿±Ç¡£
LET B(1,1)=10 ! ÅÅή¸»¤«¤é10A¤òή¤¹¡£¡Ã¼»Ò¤Ï1V¡£
LET B(2,1)=0 ! ¥¥ë¥Ò¥Û¥Ã¥Õ¤Îˡ§¤«¤é ¥¼¥í¤Ç¤¢¤ë¡£
LET B(3,1)=0 ! ¥¥ë¥Ò¥Û¥Ã¥Õ¤Îˡ§¤«¤é ¥¼¥í¤Ç¤¢¤ë¡£
LET B(4,1)=0 ! ¥¥ë¥Ò¥Û¥Ã¥Õ¤Îˡ§¤«¤é ¥¼¥í¤Ç¤¢¤ë¡£
LET B(5,1)=0 ! ¤³¤³¤Ë0¤ÎÃͤòÆþ¤ì V5=K*V4 ¤òÈ¿±Ç¡£
MAT T=INV(A)
MAT EOUT=T*B
! PRINT "FF=";FF
! MAT PRINT EOUT
LET EE1=EOUT(1,1)
LET EE2=EOUT(2,1)
LET EE3=EOUT(3,1)
LET EE4=EOUT(4,1)
LET EE5=EOUT(5,1)
PRINT
LET FREQ(P,2)=20*LOG10(ABS(EE5))
! LET FREQ(P,3)=20*LOG10(ABS(EE3))
LET G5=(ATN(IM(EE5)/RE(EE5)))
IF FF>750 THEN LET G5=G5-180
IF G5>0 THEN LET G5=G5-180
LET FREQ(P,4)=G5
! LET G3=(ATN(IM(EE3)/RE(EE3)))
! IF FF>750 THEN LET G3=G3-180
! LET FREQ(P,5)=G3
NEXT P
PRINT "K=";K
PRINT "ÈÖ¹æ
¼þÇÈ
¿ô E5
E3
¦È5 ¦È3"
FOR I=1 TO 57
PRINT USING "###": I;
PRINT USING " ###,###.#" : FREQ(I,1);
PRINT USING " ####.### dB": FREQ(I,2);
PRINT USING " ####.### dB": FREQ(I,3);
PRINT USING " ####.### ÅÙ": FREQ(I,4);
PRINT USING " ####.### ÅÙ": FREQ(I,5)
NEXT I
!¤³¤³¤«¤é¤Ï¡¢»³ÃæÍͤΥ°¥é¥Õ¥×¥í¥°¥é¥à¤ò»²¾È¡£
SET WINDOW 0.5,5.5, -55,5 !ɽ¼¨Îΰè
DRAW
grid(1,5) !
º¸Ã¼¤ÎÌÜÀ¹¤ê
FOR f=1 TO 6 !£ø¼´¤¬ÂпôÌÜÀ¹ f=1 TO 5 ¤Ç100k ¤Þ¤ÇÌÜÀ¹¤ë¡£
SET COLOR 1 !£±¤Ï¹õ¿§
PLOT TEXT ,AT f-0.1,+0.15: mid$("10 100 1k 10k 100k ",4*(f-1)+1,4)
NEXT f
FOR f=1 TO 6 !y¼´¤¬Ä¾ÀþÌÜÀ¹¤ê
SET COLOR 1 !£±¤Ï¹õ¿§
PLOT TEXT ,AT 0.8,-10*(f-1)-2: mid$(" 0 -25 -50 -75 -100-125 ",4*(f-1)+1,4)
NEXT f
FOR I=1 TO 57 STEP 1 !¼þÇÈ¿ô[Hz]
SET COLOR 1
PLOT LINES:LOG10(FREQ(I,1)) ,FREQ(I,2)/2.5; !ÍøÆÀ[dB]
NEXT I
PLOT LINES
! FOR I=1 TO 57 STEP 1 !¼þÇÈ¿ô[Hz]
! SET COLOR 5 !5¤Ï¿å¿§
! PLOT LINES: LOG10(FREQ(I,1)) ,FREQ(I,3)/2; !ÍøÆÀ[dB]
! NEXT I
! PLOT LINES
FOR I=1 TO 57 STEP 1 !°ÌÁê³ÑÅÙ[ÅÙ]
SET COLOR 4 !4¤ÏÀÖ¿§
PLOT LINES:LOG10(FREQ(I,1)) ,0.125*FREQ(I,4); !³ÑÅÙ[ÅÙ]
NEXT I
PLOT LINES
! FOR I=1 TO 57 STEP 1 !°ÌÁê³ÑÅÙ[ÅÙ]
! SET COLOR 3 !3¤ÏÎп§
! PLOT LINES:LOG10(FREQ(I,1)) ,0.25*FREQ(I,5); !³ÑÅÙ[ÅÙ]
! NEXT I
! PLOT LINES
FOR f=1 TO 6 !y¼´¤¬Ä¾ÀþÌÜÀ¹¤ê
SET COLOR 4
PLOT TEXT ,AT 5.1,-10*(f-1)-2: mid$(" 0 -80 -160-240-320-400 ",4*(f-1)+1,4)
NEXT f
PRINT
NEXT K ! ¤³¤³¤Ç,ÍøÆÀ K¤òÊѲ½¤µ¤»¤ë¡£
½½¿ÊBASIC¤Ï¡¤
LET N=1000
DIM A(N)
¤Î¤è¤¦¤Ê³ÈÄ¥¹½Ê¸¤òµöÍƤ¹¤ë¤¿¤á¡¤ÇÛÎóÍ×ÁǤμÂÎΰè¤ò¥Ò¡¼¥×¾å¤Ë³ÎÊݤ·¤Þ¤¹¡£
DIM B(1000)
¤Î¤è¤¦¤ËFull BASICµ¬³Ê¤ÎÈϰϤÇÀë¸À¤µ¤ì¤¿ÇÛÎó¤Ï¥¹¥¿¥Ã¥¯¥á¥â¥ê¾å¤Ë³ÎÊݤǤ¤Þ¤¹¤¬¡¤
ÆâÉô¹½Â¤¤ÎÊ£»¨¤µ¤òÈò¤±¤ë¤¿¤á¤Ë¤É¤Á¤é¤Î·Á¼°¤ÎÇÛÎó¤âÇÛÎóÍ×ÁǤϥҡ¼¥×¾å¤ËÃÖ¤¤¤Æ¤¤¤Þ¤¹¡£
REM ½½¿ÊBASICźÉÕ"\BASICw32\SAMPLE\INTERPRE.bas"¤Ë²ÃÉ®
REM ¹ÔÈÖ¹æ¤Î¤Ê¤¤¹Ô¤¬²ÃÉ®Éôʬ¡£¹ÔÈÖ¹æ¤Ïºï½ü²Ä¡£
1000 REM Full BASIC¤Î¥â¥¸¥å¡¼¥ë¤Î»È¤¤Êý¤ò¼¨¤¹¥µ¥ó¥×¥ë
1010 REM
1020 REM ¿ôÃͼ°¤Îɾ²Á¤ò¹Ô¤¦
1030 REM Áȹþ¤ß´Ø¿ô¤Ï¡¤SIN¡¤COS¡¤TAN, LOG, EXP, SQR, INT¡¤ABS¤ÈPI¤Î¤ß
1040 REM Âçʸ»ú¤È¾®Ê¸»ú¤Î¶èÊ̤Ϥ·¤Ê¤¤
1050 REM ¿ôÃͼ°¤Îʸˡ¤Ï¤Û¤ÜFull BASIC¤Ë½à¤º¤ë¤¬¡¤´Ø¿ô̾¤Ë³¤¯³ç¸Ì¤Ï¶õÇò¤òÆþ¤ì¤º¤Ë½ñ¤¯¡£
1060 REM ¿ôÃͤϡ¤¿ô»ú¤Ç»Ï¤Þ¤ê¡¤¥³¥ó¥Þ¤ò1¸Ä°Ê²¼´Þ¤à¿ô»ú¤ÎÎó¤È¤·¤Æ¤Î¤ß½ñ¤±¤ë¡£
1070 REM Îí½ü»»¥¨¥é¡¼¤Ê¤É¤Ï¹Íθ¤·¤Æ¤¤¤Ê¤¤¡£
1080 DECLARE EXTERNAL FUNCTION interpreter.expression ! ¿ôÃͼ°¤òɾ²Á¤¹¤ë´Ø¿ô
1090 DECLARE EXTERNAL STRING interpreter.s$ ! ÆþÎϹÔ
1100 DECLARE EXTERNAL NUMERIC interpreter.i ! ÆþÎϹԤÎʸ»ú°ÌÃÖ
1110 DECLARE EXTERNAL SUB interpreter.skip ! ¶õÇòʸ»ú¤òÆɤßÈô¤Ð¤¹Éû¥×¥í¥°¥é¥à
DECLARE EXTERNAL FUNCTION interpreter.str_expression$ !ʸ»úÎó¼°¤òɾ²Á¤¹¤ë´Ø¿ô
DECLARE EXTERNAL NUMERIC interpreter.vc,interpreter.sc !ÊÑ¿ô¤Î¸Ä¿ô(vc=¿ôÃÍ,sc=ʸ»úÎó)
DECLARE EXTERNAL SUB interpreter.error !¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
1120 LINE INPUT s$
1130 ! LET s$=UCASE$(s$) !ʸ»úÎó¤Î¾®Ê¸»úÊÝ»ý¤Î¤¿¤á̵¸ú¤Ë¤·¤¿
DO
LET vc,sc=0
1140 LET i=1
1150 CALL skip
IF s$(i:i)="$" THEN
LET i=i+1
CALL skip
IF s$(i:i)="=" THEN
LET i=i+1
CALL skip
PRINT str_expression$ ! ʸ»úÎó¼°É¾²Á
ELSE
CALL error("$=")
END IF
ELSE
1160 PRINT expression ! ¿ôÃͼ°É¾²Á
END IF
1170 IF i<>LEN(s$)+1 THEN PRINT "Syntax error" ! Èæ³Ó¼°¤òi<LEN(s$)¤«¤éÊѹ¹
LOOP UNTIL vc+sc=0 OR i<>LEN(s$)+1 ! Ãæ»ß¤Ï[Ãæ»ß]¥Ü¥¿¥ó¤Ç
1180 END
1190 !
1200 MODULE interpreter
! MODULE OPTION ARITHMETIC NATIVE ! DECIMAL_HIGH,COMPLEX,RATIONAL ¿ôÃÍ¥ª¥×¥·¥ç¥ó
1210 PUBLIC STRING s$
1220 PUBLIC NUMERIC i
1230 PUBLIC FUNCTION expression
1240 PUBLIC SUB skip
1250 SHARE FUNCTION term,factor,primary,numeric
PUBLIC FUNCTION str_expression$
PUBLIC NUMERIC vc,sc
PUBLIC SUB error
SHARE FUNCTION check,argument,rounding,position,bitval,v_chr,variable
SHARE FUNCTION str_primary$,str_constant$,str_naming$,sub_string$,str_input$,bitstr$
SHARE NUMERIC vari_val(20),inputv ! 20=ÊÑ¿ô¤Î¸Ä¿ô
SHARE STRING sn$,vari_name$(20),string$(20),str_name$(20)
SHARE FUNCTION F1,F2,F3,FS$ !!! ¥æ¡¼¥¶¡¼ÄêµÁ´Ø¿ô
! MODULE OPTION ANGLE DEGREES ! ³Ñ¤ÎÂ礤µ¤Îñ°Ì
! MODULE OPTION CHARACTER BYTE ! ʸ»úÎó½èÍý¤Îñ°Ì
LET inputv=0
1260 !
EXTERNAL FUNCTION F1(a) !!! ¥æ¡¼¥¶¡¼ÄêµÁ´Ø¿ô
let F1=a
END FUNCTION
EXTERNAL FUNCTION F2(a,b) !!! ¥æ¡¼¥¶¡¼ÄêµÁ´Ø¿ô
let F2=a+b
END FUNCTION
EXTERNAL FUNCTION F3(a,b,c) !!! ¥æ¡¼¥¶¡¼ÄêµÁ´Ø¿ô
let F3=a+b+c
END FUNCTION
EXTERNAL FUNCTION FS$(a$,b,c) !!! ¥æ¡¼¥¶¡¼ÄêµÁ´Ø¿ô
let FS$=a$&str$(b)&str$(c)
END FUNCTION
!
1270 EXTERNAL SUB skip
1280 DO WHILE s$(i:i)=" "
1290 LET i=i+1
1300 LOOP
1310 END SUB
1320 !
1330 EXTERNAL FUNCTION expression
1340 DECLARE NUMERIC n
1350 DECLARE STRING op$
1360 SELECT CASE s$(i:i)
1370 CASE "-"
1380 LET i=i+1
1390 CALL skip
1400 LET n=-term
1410 CASE "+"
1420 LET i=i+1
1430 CALL skip
1440 LET n=term
1450 CASE ELSE
1460 LET n=term
1470 END SELECT
1480 DO WHILE s$(i:i)="+" OR s$(i:i)="-"
1490 LET op$=s$(i:i)
1500 LET i=i+1
1510 CALL skip
1520 IF op$="+" THEN LET n=n+term ELSE LET n=n-term
1530 LOOP
1540 LET expression =n
1550 CALL skip
1560 END FUNCTION
1570 !
1580 EXTERNAL FUNCTION term
1590 DECLARE NUMERIC n
1600 DECLARE STRING op$
1610 LET n=factor
1620 DO WHILE s$(i:i)="*" OR s$(i:i)="/"
1630 LET op$=s$(i:i)
1640 LET i=i+1
1650 CALL skip
1660 IF op$="*" THEN LET n=n*factor ELSE LET n=n/factor
1670 LOOP
1680 LET term=n
1690 END FUNCTION
1700 !
1710 EXTERNAL FUNCTION factor
1720 DECLARE NUMERIC n
1730 LET n=primary
1740 DO WHILE s$(i:i)="^"
1750 LET i=i+1
1760 CALL skip
1770 LET n=n^primary
1780 LOOP
1790 LET factor=n
1800 END FUNCTION
1810 !
1820 EXTERNAL FUNCTION primary
1830 IF s$(i:i)>="0" AND s$(i:i)<="9" THEN
1840 LET primary=numeric
ELSEIF s$(i:i)="." THEN
LET primary=numeric
1850 ELSEIF UCASE$(s$(i:i+1))="PI" AND check(s$(i+2:i+2))=1 THEN ! ´Ø¿ôcheck²ÃÉ®
1860 LET i=i+2
1870 CALL skip
1880 LET primary=PI ! ÍÍý¿ô¥â¡¼¥ÉÃí°Õ
ELSEIF UCASE$(s$(i:i+2))="RND" AND check(s$(i+3:i+3))=1 THEN
LET i=i+3
CALL skip
LET primary=RND ! ÊÑ¿ôÆþÎϤ¬¤¢¤ë¿ôÃͼ°¤Ç¤ÏÅÔÅÙ¹¹¿·
ELSEIF UCASE$(s$(i:i+3))="TIME" AND check(s$(i+4:i+4))=1 THEN
LET i=i+4
CALL skip
LET primary=TIME ! ÊÑ¿ôÆþÎϤ¬¤¢¤ë¿ôÃͼ°¤Ç¤ÏÅÔÅÙ¹¹¿·
ELSEIF UCASE$(s$(i:i+3))="DATE" AND check(s$(i+4:i+4))=1 THEN
LET i=i+4
CALL skip
LET primary=DATE ! ÊÑ¿ôÆþÎϤ¬¤¢¤ë¿ôÃͼ°¤Ç¤ÏÅÔÅÙ¹¹¿·
!ELSEIF UCASE$(s$(i:i+5))="MAXNUM" AND check(s$(i+6:i+6))=1 THEN
! LET i=i+6
! CALL skip
! LET primary=MAXNUM ! ÍÍý¿ô¥â¡¼¥ÉÉÔ²Ä
1890 ELSE
1900 IF s$(i:i)="(" THEN
1910 LET i=i+1
1920 CALL skip
1930 LET primary=expression
ELSEIF UCASE$(s$(i:i+2))="F1(" THEN !!! ¥æ¡¼¥¶¡¼ÄêµÁ´Ø¿ô
LET i=i+3
CALL skip
LET Primary=F1(expression)
ELSEIF UCASE$(s$(i:i+2))="F2(" THEN !!! ¥æ¡¼¥¶¡¼ÄêµÁ´Ø¿ô
LET i=i+3
CALL skip
LET primary=F2(expression,argument)
ELSEIF UCASE$(s$(i:i+2))="F3(" THEN !!! ¥æ¡¼¥¶¡¼ÄêµÁ´Ø¿ô
LET i=i+3
CALL skip
LET primary=F3(expression,argument,argument)
1940 ELSEIF UCASE$(s$(i:i+3))="SIN(" THEN ! Ķ±Û´Ø¿ô
1950 LET i=i+4
1960 CALL skip
1970 LET Primary=SIN(expression)
1980 ELSEIF UCASE$(s$(i:i+3))="COS(" THEN ! Ķ±Û´Ø¿ô
1990 LET i=i+4
2000 CALL skip
2010 LET Primary=COS(expression)
2020 ELSEIF UCASE$(s$(i:i+3))="TAN(" THEN ! Ķ±Û´Ø¿ô
2030 LET i=i+4
2040 CALL skip
2050 LET Primary=TAN(expression)
2060 ELSEIF UCASE$(s$(i:i+3))="LOG(" THEN ! Ķ±Û´Ø¿ô
2070 LET i=i+4
2080 CALL skip
2090 LET Primary=LOG(expression)
2100 ELSEIF UCASE$(s$(i:i+3))="EXP(" THEN ! Ķ±Û´Ø¿ô
2110 LET i=i+4
2120 CALL skip
2130 LET Primary=EXP(expression)
2140 ELSEIF UCASE$(s$(i:i+3))="SQR(" THEN ! ÍÍý¿ô¥â¡¼¥ÉÃí°Õ
2150 LET i=i+4
2160 CALL skip
2170 LET Primary=SQR(expression)
2180 ELSEIF UCASE$(s$(i:i+3))="INT(" THEN
2190 LET i=i+4
2200 CALL skip
2210 LET Primary=INT(expression)
2220 ELSEIF UCASE$(s$(i:i+3))="ABS(" THEN
2230 LET i=i+4
2240 CALL skip
2250 LET Primary=ABS(expression)
ELSEIF UCASE$(s$(i:i+3))="MOD(" THEN
LET i=i+4
CALL skip
LET primary=MOD(expression,argument)
ELSEIF UCASE$(s$(i:i+5))="ROUND(" THEN
LET i=i+6
CALL skip
LET primary=rounding
ELSEIF UCASE$(s$(i:i+4))="CEIL(" THEN
LET i=i+5
CALL skip
LET Primary=CEIL(expression)
ELSEIF UCASE$(s$(i:i+3))="SGN(" THEN
LET i=i+4
CALL skip
LET Primary=SGN(expression)
ELSEIF UCASE$(s$(i:i+2))="IP(" THEN
LET i=i+3
CALL skip
LET Primary=IP(expression)
ELSEIF UCASE$(s$(i:i+2))="FP(" THEN
LET i=i+3
CALL skip
LET Primary=FP(expression)
ELSEIF UCASE$(s$(i:i+9))="REMAINDER(" THEN
LET i=i+10
CALL skip
LET primary=REMAINDER(expression,argument)
ELSEIF UCASE$(s$(i:i+8))="TRUNCATE(" THEN
LET i=i+9
CALL skip
LET primary=TRUNCATE(expression,argument)
ELSEIF UCASE$(s$(i:i+4))="LOG2(" THEN ! Ķ±Û´Ø¿ô
LET i=i+5
CALL skip
LET Primary=LOG2(expression)
ELSEIF UCASE$(s$(i:i+5))="LOG10(" THEN ! Ķ±Û´Ø¿ô
LET i=i+6
CALL skip
LET Primary=LOG10(expression)
ELSEIF UCASE$(s$(i:i+3))="CSC(" THEN ! Ķ±Û´Ø¿ô
LET i=i+4
CALL skip
LET Primary=CSC(expression)
ELSEIF UCASE$(s$(i:i+3))="SEC(" THEN ! Ķ±Û´Ø¿ô
LET i=i+4
CALL skip
LET Primary=SEC(expression)
ELSEIF UCASE$(s$(i:i+3))="COT(" THEN ! Ķ±Û´Ø¿ô
LET i=i+4
CALL skip
LET Primary=COT(expression)
ELSEIF UCASE$(s$(i:i+4))="ASIN(" THEN ! Ķ±Û´Ø¿ô
LET i=i+5
CALL skip
LET Primary=ASIN(expression)
ELSEIF UCASE$(s$(i:i+4))="ACOS(" THEN ! Ķ±Û´Ø¿ô
LET i=i+5
CALL skip
LET Primary=ACOS(expression)
ELSEIF UCASE$(s$(i:i+3))="ATN(" THEN ! Ķ±Û´Ø¿ô
LET i=i+4
CALL skip
LET Primary=ATN(expression)
ELSEIF UCASE$(s$(i:i+5))="ANGLE(" THEN ! Ķ±Û´Ø¿ô
LET i=i+6
CALL skip
LET primary=ANGLE(expression,argument)
ELSEIF UCASE$(s$(i:i+4))="SINH(" THEN ! Ķ±Û´Ø¿ô
LET i=i+5
CALL skip
LET Primary=SINH(expression)
ELSEIF UCASE$(s$(i:i+4))="COSH(" THEN ! Ķ±Û´Ø¿ô
LET i=i+5
CALL skip
LET Primary=COSH(expression)
ELSEIF UCASE$(s$(i:i+4))="TANH(" THEN ! Ķ±Û´Ø¿ô
LET i=i+5
CALL skip
LET Primary=TANH(expression)
!ELSEIF UCASE$(s$(i:i+3))="EPS(" THEN ! ÍÍý¿ô¥â¡¼¥ÉÉÔ²Ä
! LET i=i+4
! CALL skip
! LET Primary=EPS(expression)
ELSEIF UCASE$(s$(i:i+3))="DEG(" THEN
LET i=i+4
CALL skip
LET Primary=DEG(expression)
ELSEIF UCASE$(s$(i:i+3))="RAD(" THEN
LET i=i+4
CALL skip
LET Primary=RAD(expression)
ELSEIF UCASE$(s$(i:i+3))="MAX(" THEN
LET i=i+4
CALL skip
LET primary=MAX(expression,argument)
ELSEIF UCASE$(s$(i:i+3))="MIN(" THEN
LET i=i+4
CALL skip
LET primary=MIN(expression,argument)
ELSEIF UCASE$(s$(i:i+4))="FACT(" THEN !½½¿ÊBASICÆȼ«³ÈÄ¥
LET i=i+5
CALL skip
LET Primary=FACT(expression)
ELSEIF UCASE$(s$(i:i+4))="PERM(" THEN !½½¿ÊBASICÆȼ«³ÈÄ¥
LET i=i+5
CALL skip
LET primary=PERM(expression,argument)
ELSEIF UCASE$(s$(i:i+4))="COMB(" THEN !½½¿ÊBASICÆȼ«³ÈÄ¥
LET i=i+5
CALL skip
LET primary=COMB(expression,argument)
ELSEIF UCASE$(s$(i:i+10))="COLORINDEX(" THEN !½½¿ÊBASICÆȼ«³ÈÄ¥
LET i=i+11
CALL skip
LET primary=COLORINDEX(expression,argument,argument)
!ELSEIF UCASE$(s$(i:i+7))="COMPLEX(" THEN !Ê£ÁÇ´Ø¿ô
! LET i=i+8
! CALL skip
! LET primary=COMPLEX(expression,argument)
!ELSEIF UCASE$(s$(i:i+2))="RE(" THEN !Ê£ÁÇ´Ø¿ô
! LET i=i+3
! CALL skip
! LET Primary=RE(expression)
!ELSEIF UCASE$(s$(i:i+2))="IM(" THEN !Ê£ÁÇ´Ø¿ô
! LET i=i+3
! CALL skip
! LET Primary=IM(expression)
!ELSEIF UCASE$(s$(i:i+4))="CONJ(" THEN !Ê£ÁÇ´Ø¿ô
! LET i=i+5
! CALL skip
! LET Primary=CONJ(expression)
!ELSEIF UCASE$(s$(i:i+3))="ARG(" THEN !Ê£ÁÇ´Ø¿ô
! LET i=i+4
! CALL skip
! LET Primary=ARG(expression)
!ELSEIF UCASE$(s$(i:i+5))="NUMER(" THEN !ÍÍý¿ô¥â¡¼¥ÉÀìÍÑ
! LET i=i+6
! CALL skip
! LET Primary=NUMER(expression)
!ELSEIF UCASE$(s$(i:i+5))="DENOM(" THEN !ÍÍý¿ô¥â¡¼¥ÉÀìÍÑ
! LET i=i+6
! CALL skip
! LET Primary=DENOM(expression)
!ELSEIF UCASE$(s$(i:i+3))="GCD(" THEN !ÍÍý¿ô¥â¡¼¥ÉÀìÍÑ
! LET i=i+4
! CALL skip
! LET primary=GCD(expression,argument)
!ELSEIF UCASE$(s$(i:i+6))="INTSQR(" THEN !ÍÍý¿ô¥â¡¼¥ÉÀìÍÑ
! LET i=i+7
! CALL skip
! LET Primary=INTSQR(expression)
!ELSEIF UCASE$(s$(i:i+7))="INTLOG2(" THEN !ÍÍý¿ô¥â¡¼¥ÉÀìÍÑ
! LET i=i+8
! CALL skip
! LET Primary=INTLOG2(expression)
ELSEIF UCASE$(s$(i:i+3))="LEN(" THEN
LET i=i+4
CALL skip
LET primary=LEN(str_expression$)
ELSEIF UCASE$(s$(i:i+3))="POS(" THEN
LET i=i+4
CALL skip
LET primary=position
ELSEIF UCASE$(s$(i:i+3))="VAL(" THEN
LET i=i+4
CALL skip
LET primary=VAL(str_expression$)
ELSEIF UCASE$(s$(i:i+3))="ORD(" THEN
LET i=i+4
CALL skip
LET primary=ORD(str_expression$)
ELSEIF UCASE$(s$(i:i+4))="BVAL(" THEN
LET i=i+5
CALL skip
LET primary=bitval
ELSEIF UCASE$(s$(i:i+4))="BLEN(" THEN !½½¿ÊBASICÆȼ«³ÈÄ¥
LET i=i+5
CALL skip
LET primary=BLEN(str_expression$)
ELSEIF v_chr(s$(i:i))=1 THEN
LET primary=variable ! ÊÑ¿ô
CALL skip
EXIT FUNCTION
2260 ELSE
CALL error("FUNCTION primary")
2270 PRINT "Syntax error"
2280 STOP
2290 END IF
2300 IF s$(i:i)=")" THEN
2310 LET i=i+1
2320 CALL skip
2330 ELSE
CALL error("FUNCTION primary")
2340 PRINT "Syntax error"
2350 STOP
2360 END IF
2370 END IF
2380 END FUNCTION
2390 !
2400 EXTERNAL FUNCTION numeric
2410 DECLARE NUMERIC i0
2420 CALL skip
2430 LET i0=i
IF s$(i:i)="." THEN ! ¾®¿ôÅÀ¤Ç»Ï¤Þ¤ë
LET i=i+1
ELSE
2440 DO WHILE s$(i:i)>="0" AND s$(i:i)<="9"
2450 LET i=i+1
2460 LOOP
2470 IF s$(i:i)="." THEN LET i=i+1
END IF
2480 DO WHILE s$(i:i)>="0" AND s$(i:i)<="9"
2490 LET i=i+1
2500 LOOP
IF LEN(s$)>=i AND UCASE$(s$(i:i))="E" THEN ! »Ø¿ôÉô
LET i=i+1
IF s$(i:i)="+" OR s$(i:i)="-" THEN LET i=i+1
DO WHILE s$(i:i)>="0" AND s$(i:i)<="9"
LET i=i+1
LOOP
END IF
2510 LET numeric=VAL(s$(i0:i-1))
2520 CALL skip
2530 END FUNCTION
2540 !
![¤½¤Î£²]¤Ø³¤¯
! [¤½¤Î£²]
! *°Ê²¼¤¹¤Ù¤Æ²ÃÉ®Éôʬ*
EXTERNAL FUNCTION check(c$) !! ͽÌó¸ì¤Î¸å³»ú
DECLARE STRING p$
LET check=-1
DO
READ IF MISSING THEN EXIT DO : p$
IF c$=p$ THEN LET check=1
LOOP
DATA " " , "+" , "-" , "*" , "/" , "^" , "," , ")" , ""
END FUNCTION
!
EXTERNAL FUNCTION argument !! °ú¿ô
CALL skip
IF s$(i:i)="," THEN
LET i=i+1
CALL skip
ELSE
CALL error("FUNCTION argument,°ú¿ô")
END IF
LET argument=expression
END FUNCTION
!
EXTERNAL FUNCTION rounding !! ´Ø¿ôROUND¤Î¼±ÊÌ
DECLARE NUMERIC a
LET a=expression
IF s$(i:i)="," THEN
LET i=i+1
CALL skip
LET rounding=ROUND(a,expression)
ELSEIF s$(i:i)=")" THEN
LET rounding=ROUND(a) ! ½½¿ÊBASICÆȼ«³ÈÄ¥
ELSE
CALL error("FUNCTION rounding,´Ø¿ôROUND")
END IF
END FUNCTION
!
EXTERNAL FUNCTION position !! ´Ø¿ôPOS¤Î¼±ÊÌ
DECLARE STRING aa$,bb$
LET aa$=str_expression$
IF s$(i:i)="," THEN
LET i=i+1
CALL skip
LET bb$=str_expression$
IF s$(i:i)=")" THEN
LET position=POS(aa$,bb$)
ELSEIF s$(i:i)="," THEN
LET i=i+1
CALL skip
LET position=POS(aa$,bb$,expression)
ELSE
CALL error("FUNCTION position,´Ø¿ôPOS")
END IF
ELSE
CALL error("FUNCTION position,´Ø¿ôPOS")
END IF
END FUNCTION
!
EXTERNAL FUNCTION bitval !! ´Ø¿ôBVAL¤Î¼±ÊÌ
DECLARE STRING aa$
LET aa$=str_primary$
IF s$(i:i)="," THEN
LET i=i+1
CALL skip
IF s$(i:i)="2" THEN
LET i=i+1
CALL skip
LET bitval=BVAL(aa$,2)
ELSEIF s$(i:i+1)="16" THEN
LET i=i+2
CALL skip
LET bitval=BVAL(aa$,16)
ELSE
CALL error("FUNCTION bitval,´Ø¿ôBVAL")
END IF
ELSE
CALL error("FUNCTION bitval,´Ø¿ôBVAL")
END IF
END FUNCTION
!
EXTERNAL FUNCTION v_chr(c$) !! ÊÑ¿ô̾ʸ»ú
IF c$>="A" AND c$<="Z" OR c$>="a" AND c$<="z" OR c$>="¤¡" THEN !ÀèƬʸ»úµÚ¤Ó¤½¤ì°Ê¹ß
LET v_chr=1
ELSEIF c$>="0" AND c$<="9" OR c$="_" OR c$>="£°" THEN ! 2ʸ»úÌܰʹß
LET v_chr=2
ELSE
LET v_chr=-1
END IF
END FUNCTION
!
EXTERNAL FUNCTION variable !! ÊÑ¿ô
DECLARE NUMERIC j,vi
DECLARE STRING vn$,aa$,vs$
LET vn$=""
DO WHILE v_chr(s$(i:i))>=1
LET vn$=vn$&s$(i:i)
LET i=i+1
LOOP
FOR j=1 TO vc
IF UCASE$(vn$)=UCASE$(vari_name$(j)) THEN
LET variable=vari_val(j) ! ´û½Ð¤ÎÊÑ¿ô
EXIT FUNCTION
END IF
NEXT j
LET vc=vc+1
LET vari_name$(vc)=vn$
IF inputv=0 THEN
DO
LINE INPUT PROMPT vn$&"=" : aa$ ! ÊÑ¿ô¤Ø¤ÎÆþÎÏ
LOOP UNTIL aa$<>""
ELSE
CALL error("FUNCTION variable,ÊÑ¿ôÆþÎÏ")
END IF
LET vs$=s$
LET vi=i
LET s$=LTRIM$(aa$)
LET i=1
LET inputv=1
LET vari_val(vc)=expression ! ÊÑ¿ô¤ËÆþÎϤ·¤¿¿ôÃͼ°¤Î½èÍý
LET inputv=0
LET s$=vs$
LET i=vi
LET variable=vari_val(vc)
END FUNCTION
!
!
EXTERNAL FUNCTION str_expression$ !! ʸ»úÎó¼°
DECLARE STRING str_n$
LET str_n$=str_primary$
DO WHILE s$(i:i)="&"
LET i=i+1
CALL skip
LET str_n$=str_n$&str_primary$
LOOP
LET str_expression$ =str_n$
CALL skip
END FUNCTION
!
EXTERNAL FUNCTION str_primary$ !! ʸ»úÎó°ì¼¡»Ò
DECLARE NUMERIC j
IF s$(i:i)="""" THEN
LET i=i+1
LET str_primary$=str_constant$
ELSEIF UCASE$(s$(i:i+4))="DATE$" THEN
LET i=i+5
CALL skip
LET str_primary$=DATE$ !ÊÑ¿ôÆþÎϤ¬¤¢¤ë¿ôÃͼ°¤Ç¤ÏÅÔÅÙ¹¹¿·
ELSEIF UCASE$(s$(i:i+4))="TIME$" THEN
LET i=i+5
CALL skip
LET str_primary$=TIME$ !ÊÑ¿ôÆþÎϤ¬¤¢¤ë¿ôÃͼ°¤Ç¤ÏÅÔÅÙ¹¹¿·
ELSE
IF v_chr(s$(i:i))=1 THEN
LET sn$=str_naming$ ! ʸ»úÎó´Ø¿ô/ÊÑ¿ô̾
FOR j=1 TO sc
IF UCASE$(sn$)=UCASE$(str_name$(j)) THEN
CALL skip
IF s$(i:i)="(" THEN
LET i=i+1
CALL skip
LET str_primary$=sub_string$(string$(j)) !Éôʬʸ»úÎó
ELSE
LET str_primary$=string$(j) ! ´û½Ð¤Îʸ»úÎóÊÑ¿ô
END IF
EXIT FUNCTION
END IF
NEXT j
ELSE
CALL error("FUNCTION str_primary$,ʸ»úÎó°ì¼¡»Ò")
END IF
SELECT CASE UCASE$(sn$)&s$(i:i)
CASE "FS$(" !!! ¥æ¡¼¥¶¡¼ÄêµÁ´Ø¿ô
LET i=i+1
CALL skip
LET str_primary$=FS$(str_expression$,argument,argument)
CASE "REPEAT$("
LET i=i+1
CALL skip
LET str_primary$=REPEAT$(str_expression$,argument)
CASE "STR$("
LET i=i+1
CALL skip
LET str_primary$=STR$(expression)
CASE "USING$("
LET i=i+1
CALL skip
LET str_primary$=USING$(str_expression$,argument)
CASE "CHR$("
LET i=i+1
CALL skip
LET str_primary$=CHR$(expression)
CASE "LCASE$("
LET i=i+1
CALL skip
LET str_primary$=LCASE$(str_expression$)
CASE "UCASE$("
LET i=i+1
CALL skip
LET str_primary$=UCASE$(str_expression$)
CASE "LTRIM$("
LET i=i+1
CALL skip
LET str_primary$=LTRIM$(str_expression$)
CASE "RTRIM$("
LET i=i+1
CALL skip
LET str_primary$=RTRIM$(str_expression$)
CASE "BSTR$("
LET i=i+1
CALL skip
LET str_primary$=bitstr$
CASE "SUBSTR$(" ! ½½¿ÊBASICÆȼ«³ÈÄ¥
LET i=i+1
CALL skip
LET str_primary$=SUBSTR$(str_expression$,argument,argument)
CASE "MID$(" ! ½½¿ÊBASICÆȼ«³ÈÄ¥
LET i=i+1
CALL skip
LET str_primary$=MID$(str_expression$,argument,argument)
CASE "LEFT$(" ! ½½¿ÊBASICÆȼ«³ÈÄ¥
LET i=i+1
CALL skip
LET str_primary$=LEFT$(str_expression$,argument)
CASE "RIGHT$(" ! ½½¿ÊBASICÆȼ«³ÈÄ¥
LET i=i+1
CALL skip
LET str_primary$=RIGHT$(str_expression$,argument)
CASE ELSE
LET str_primary$=str_input$ ! ʸ»úÎóÆþÎÏ
CALL skip
EXIT FUNCTION
END SELECT
IF s$(i:i)=")" THEN
LET i=i+1
CALL skip
ELSE
CALL error("FUNCTION str_primary$")
END IF
END IF
END FUNCTION
!
EXTERNAL FUNCTION str_constant$ !! ʸ»úÎóÄê¿ô
DECLARE STRING cc$
LET cc$=""
DO
IF s$(i:i)="""" THEN
IF s$(i+1:i+1)="""" THEN ! [""]¤Î¼±ÊÌ
LET cc$=cc$&s$(i:i)
LET i=i+2
ELSE
LET i=i+1
EXIT DO
END IF
ELSE
LET cc$=cc$&s$(i:i)
LET i=i+1
IF i>LEN(s$)+1 THEN
CALL error("FUNCTION str_constant$,ʸ»úÎóÄê¿ô")
EXIT DO
END IF
END IF
LOOP
CALL skip
LET str_constant$=cc$
END FUNCTION
!
EXTERNAL FUNCTION str_naming$ !! ʸ»úÎó´Ø¿ô/ÊÑ¿ô̾
LET sn$=""
DO WHILE v_chr(s$(i:i))>=1
LET sn$=sn$&s$(i:i)
LET i=i+1
LOOP
IF s$(i:i)="$" THEN
LET str_naming$=sn$&s$(i:i)
LET i=i+1
ELSE
CALL error("FUNCTION str_naming$,ʸ»úÎó´Ø¿ô/ÊÑ¿ô̾")
END IF
END FUNCTION
!
EXTERNAL FUNCTION sub_string$(ss$) !! Éôʬʸ»úÎó
DECLARE NUMERIC a
LET a=expression
IF s$(i:i)=":" THEN
LET i=i+1
CALL skip
LET sub_string$=ss$(a:expression)
IF s$(i:i)=")" THEN
LET i=i+1
CALL skip
ELSE
CALL error("FUNCTION sub_string$,Éôʬʸ»úÎó")
END IF
ELSE
CALL error("FUNCTION sub_string$,Éôʬʸ»úÎó")
END IF
END FUNCTION
!
EXTERNAL FUNCTION str_input$ !! ʸ»úÎóÆþÎÏ
DECLARE NUMERIC j,vi
DECLARE STRING vs$
LET sc=sc+1
LET str_name$(sc)=sn$
IF inputv=0 THEN
LINE INPUT PROMPT sn$&"=" : string$(sc)
ELSE
CALL error("FUNCTION str_input$,ʸ»úÎóÆþÎÏ")
END IF
LET j=1
DO WHILE string$(sc)(j:j)=" "
LET j=j+1
LOOP
IF string$(sc)(j:j)="$" THEN
LET j=j+1
DO WHILE string$(sc)(j:j)=" "
LET j=j+1
LOOP
IF string$(sc)(j:j)="=" THEN
LET vs$=s$
LET vi=i
LET s$=string$(sc)(j+1:LEN(string$(sc)))
LET s$=LTRIM$(s$)
LET i=1
LET inputv=1
LET string$(sc)=str_expression$ ! ʸ»úÎóÊÑ¿ô¤ËÆþÎϤ·¤¿Ê¸»úÎ󼰤νèÍý
LET inputv=0
LET s$=vs$
LET i=vi
END IF
END IF
LET str_input$=string$(sc)
END FUNCTION
!
EXTERNAL FUNCTION bitstr$ !! ´Ø¿ôBSTR$¤Î¼±ÊÌ
DECLARE NUMERIC a
LET a=expression
IF s$(i:i)="," THEN
LET i=i+1
CALL skip
IF s$(i:i)="2" THEN
LET i=i+1
CALL skip
LET bitstr$=BSTR$(a,2)
ELSEIF s$(i:i+1)="16" THEN
LET i=i+2
CALL skip
LET bitstr$=BSTR$(a,16)
ELSE
CALL error("FUNCTION bitstr$,´Ø¿ôBSTR$")
END IF
ELSE
CALL error("FUNCTION bitstr$,´Ø¿ôBSTR$")
END IF
END FUNCTION
!
EXTERNAL SUB error(e$) !! ¥¨¥é¡¼É½¼¨
PRINT "Error (";e$;")"
!STOP
END SUB
!
2550 END MODULE
L ¤ÎÅÅ°µ¹ß²¼¡á¡¡ L * dI'(t)/dt¡¡=L*s*I'(t)¡¡¡¡¡¡¡¡¡¡=¡¡sL * I'(t)
C ¤ÎÅÅ°µ¹ß²¼¡á(1/C)* ¢é I'(t)dt¡¡=(1/C)*(1/s )*I'(t) =(1/sC) * I'(t)
R ¤ÎÅÅ°µ¹ß²¼¡á¡¡ R * I'(t)
L ¤ÎÅÅ°µ¹ß²¼¡á¡¡ L * dI(t)/dt¡¡=L*j¦Ø*I(t)¡¡¡¡¡¡¡¡ =¡¡j¦ØL * I(t)
C ¤ÎÅÅ°µ¹ß²¼¡á(1/C)* ¢é I(t)dt¡¡=(1/C)*(1/j¦Ø)*I(t) =(1/j¦ØC) * I(t)
R ¤ÎÅÅ°µ¹ß²¼¡á¡¡ R * I(t)
!¼°¡ÊÃæÃֵˡ¡Ë¤Îɾ²Á - £±ÊÑ¿ô¿¹à¼°¤Î·¸¿ô¤¬À°¿ô¤Î¾ì¹ç¡¡¢¨UBASICÁêÅö
DECLARE EXTERNAL SUB expr.eval
!LET s$="(x-2)*(x-3)*(x-4)*(x-5)"
LET s$="(x^2-2*x+3)^2"
!LET s$="(x^5-5*x^3+5*x^2-1)/(x^2+3*x+1)" !¾¦ x^3-3*x^2+3*x-1¡¢Í¾¤ê 0
!LET s$="mod(2*x^3-13*x^2-26*x-15,x^2-2*x+3)" !¾¦ 2*x-9¡¢Í¾¤ê -50*x+12
!LET s$="gcd(3*x^2+5*x-2,3*x^2-7*x+2)" !12*x-4 { 3*x-1 }
!LET s$="lcm(3*x^2+5*x-2,3*x^2-7*x+2)" !3/4*x^3-1/4*x^2-3*x+1 { (x+2)*(x-2)*(3*x-1) }
!LET s$="lcm(x^3-16*x,x^3-8*x^2+16*x)"
DIM a(0 TO 8) !·¸¿ô a(n)*x^n+a(n-1)*x^(n-1)+ ¡Ä +a(1)*x+a(0)
CALL eval(s$, a,rc) !¼°
MAT PRINT a; !x^0,x^1,x^2, ¡Ä ¤Î½ç¡¡debug
IF rc=0 THEN CALL poly_disp(a) !·ë²Ì¤òɽ¼¨¤¹¤ë
END
MODULE expr
PUBLIC NUMERIC p,ErrNo !¶¦ÄÌÊÑ¿ô
!¡ü²òÀÏÉôʬ
!²¼°Ì¤Î¶¦Ḁ̈롼¥Á¥ó
EXTERNAL FUNCTION token$(s$) !£±Ê¸»úÆɤ߹þ¤à
CALL EatSpace(s$)
IF p<=LEN(s$) THEN LET token$=s$(p:p) ELSE LET token$=""
END FUNCTION
EXTERNAL SUB EatSpace(s$) !¶õÇò¤òÆɤßÈô¤Ð¤¹
DO WHILE s$(p:p)=" " AND p<=LEN(s$)
LET p=p+1
LOOP
END SUB
EXTERNAL SUB CheckToken(s$,L$) !ʸ»ú¤ò³Îǧ¤¹¤ë
CALL EatSpace(s$)
IF UCASE$(s$(p:p+LEN(L$)-1))<>L$ THEN CALL Error(L$&"¤¬¤¢¤ê¤Þ¤»¤ó¡£")
LET p=p+LEN(L$) !eat it
END SUB
EXTERNAL SUB Error(x$) !¥á¥Ã¥»¡¼¥¸¤òɽ¼¨¤¹¤ë
PRINT
PRINT x$; p
LET errNo=1
END SUB
!¾å°Ì¥ë¡¼¥Á¥ó
PUBLIC SUB eval
EXTERNAL SUB eval(s$, v(),rc) !¼°¤Îɾ²Á
LET errNo=0 !¥¨¥é¡¼¥³¡¼¥É
LET p=1 !ʸ»úÎó¤Ø¤Î¥Ý¥¤¥ó¥¿
CALL expression(s$, v) !·×»»¤¹¤ë
LET rc=errNo
END SUB
EXTERNAL SUB expression(s$, v()) !¼°
DIM w(0 TO UBOUND(v))
LET t$=token$(s$)
IF t$="-" THEN !Éä¹æ¤Ê¤é
LET p=p+1 !eat it
CALL term(s$, v)
IF errNo<>0 THEN EXIT SUB
CALL op_neg(v, v) !v=-v
ELSE
IF t$="+" THEN LET p=p+1 !eat it
CALL term(s$, v)
END IF
IF errNo<>0 THEN EXIT SUB
LET t$=token$(s$)
DO WHILE t$="+" OR t$="-" !²Ã»»¡¢¸º»»¤Ê¤é
LET p=p+1 !eat it
CALL term(s$, w)
IF errNo<>0 THEN EXIT SUB
IF t$="+" THEN !·×»»¤¹¤ë
CALL op_add(v,w, v) !v=v+w
ELSE
CALL op_sub(v,w, v) !v=v-w
END IF
IF errNo<>0 THEN EXIT SUB
LET t$=token$(s$) !¼¡¤Ø
LOOP
END SUB
EXTERNAL SUB term(s$, v()) !¹à
DIM w(0 TO UBOUND(v))
CALL factor(s$,v)
IF errNo<>0 THEN EXIT SUB
LET t$=token$(s$)
DO WHILE t$="*" OR t$="/" !¾è»»¡¢½ü»»¤Ê¤é
LET p=p+1 !eat it
CALL factor(s$,w)
IF errNo<>0 THEN EXIT SUB
IF t$="*" THEN !·×»»¤¹¤ë
CALL op_mul(v,w, v) !v=v*w
ELSE
CALL op_div(v,w, v) !v=v/w
END IF
IF errNo<>0 THEN EXIT SUB
LET t$=token$(s$) !¼¡¤Ø
LOOP
END SUB
EXTERNAL SUB factor(s$, v()) !°ø»Ò
DIM w(0 TO UBOUND(v))
LET t$=token$(s$)
IF t$="(" THEN !³ç¸Ì¤Ê¤é
LET p=p+1 !eat it
CALL expression(s$,w) !¼°
IF errNo<>0 THEN EXIT SUB
MAT v=w
CALL CheckToken(s$,")") !ÊĤ¸³ç¸Ì¤«³Îǧ¤¹¤ë
ELSE
CALL num(s$,v)
END IF
IF errNo<>0 THEN EXIT SUB
LET t$=token$(s$)
DO WHILE t$="^" !¤Ù¤¾è¤Ê¤é
LET p=p+1 !eat it
LET t$=token$(s$)
IF t$="(" THEN !³ç¸Ì¤Ê¤é
LET p=p+1 !eat it
CALL expression(s$,w) !¼°
IF errNo<>0 THEN EXIT SUB
CALL CheckToken(s$,")") !ÊĤ¸³ç¸Ì¤«³Îǧ¤¹¤ë
ELSE
CALL num(s$,w)
END IF
IF errNo<>0 THEN EXIT SUB
CALL op_pow(v,w, v) !·×»»¤¹¤ë¡¡v=v^w
IF errNo<>0 THEN EXIT SUB
LET t$=token$(s$) !¼¡¤Ø
LOOP
END SUB
EXTERNAL SUB num(s$,v()) !¿ô
DIM w(0 TO UBOUND(v)),x(0 TO UBOUND(v))
LET c=fnc(s$)
IF c>0 THEN !´Ø¿ô¤Ê¤é
LET t$=token$(s$)
IF t$="(" THEN !³ç¸Ì¤Ê¤é
LET p=p+1 !eat it
CALL expression(s$,w) !°ú¿ô£±
IF errNo<>0 THEN EXIT SUB
MAT v=w
CALL CheckToken(s$,",") !¥«¥ó¥Þ¤«³Îǧ¤¹¤ë
CALL expression(s$,w) !°ú¿ô£²
IF errNo<>0 THEN EXIT SUB
IF c=1 THEN !modpow(a,n,b)·Á¼°
CALL CheckToken(s$,",") !¥«¥ó¥Þ¤«³Îǧ¤¹¤ë
CALL expression(s$,w) !°ú¿ô£³
IF errNo<>0 THEN EXIT SUB
MAT x=w
CALL set_fnc3(c,v,w,x, v) !v=fnc(v,w,x)
ELSE
CALL set_fnc2(c,v,w, v) !v=fnc(v,w)
END IF
IF errNo<>0 THEN EXIT SUB
CALL CheckToken(s$,")") !ÊĤ¸³ç¸Ì¤«³Îǧ¤¹¤ë
ELSE
CALL Error("ÉÔÀµ¤Êʸ»ú¤Ç¤¹¡£")
END IF
ELSE
LET c=var(s$)
IF c>0 THEN !ÊÑ¿ô¤Ê¤é
CALL set_var(c, v)
ELSE
LET c=number(s$)
IF c>=0 THEN !Äê¿ô¡Ê¿ôÃ͡ˤʤé
CALL set_number(c, v)
ELSE
CALL Error("ÉÔÀµ¤Êʸ»ú¤Ç¤¹¡£")
END IF
END IF
END IF
END SUB
EXTERNAL FUNCTION fnc(s$) !´Ø¿ô
DATA "MODPOW","MODINV","MOD","GCD","LCM" !¢¨Ê¸»úŤ¬Â礤¤½ç
LET k=0
DO
LET k=k+1
READ IF MISSING THEN EXIT DO: d$
IF UCASE$(s$(p:p+LEN(d$)-1))=UCASE$(d$) THEN !°ìÃפ·¤¿¤é
LET p=p+LEN(d$)
LET fnc=k
EXIT FUNCTION
END IF
LOOP
LET fnc=-1
END FUNCTION
EXTERNAL FUNCTION var(s$) !ÊÑ¿ô
LET t$=UCASE$(token$(s$)) !Âçʸ»ú¤Ø
IF "A"<=t$ AND t$<="Z" THEN
!!!IF t$="X" THEN
LET p=p+1 !eat it
LET var=ORD(t$)-ORD("@") !¥ª¥Õ¥»¥Ã¥È¡¡@=0,A=1,B=2,¡Ä,Z=26
ELSE
LET var=-1
END IF
END FUNCTION
EXTERNAL FUNCTION number(s$) !¿ôÃÍ¡Ê£°¡¢Àµ¤ÎÀ°¿ô¡Ë
LET i0=p !ÀèƬ°ÌÃÖ¤òµÏ¿¤¹¤ë
LET t$=token$(s$)
DO WHILE t$>="0" AND t$<="9"
LET p=p+1
LET t$=token$(s$)
LOOP
LET number=-1
IF p>i0 THEN LET number=VAL(s$(i0:p-1)) !¿ô»úÎó¤ÎÈϰϤòÀÚ¤ê¼è¤ë
END FUNCTION
!¡ü±é»»Éôʬ¡¡¢¨¡Ö¿ô¤ÎÁȡפ˱þ¤¸¤Æ±é»»¤òÄêµÁ¤¹¤ë
EXTERNAL SUB op_neg(v1(), v()) !Éä¹æ¡ÊÉé¡Ë
MAT v=(-1)*v1
END SUB
EXTERNAL SUB op_add(v1(),v2(), v()) !²Ã»»
MAT v=v1+v2
END SUB
EXTERNAL SUB op_sub(v1(),v2(), v()) !¸º»»
MAT v=v1-v2
END SUB
EXTERNAL SUB op_mul(v1(),v2(), v()) !¾è»»
LET N=UBOUND(v)
DIM w(0 TO N*2) !·å¿ô¤Ï£²Çܤˤʤë
MAT w=ZER
FOR i=0 TO N !·¸¿ô
FOR j=0 TO N
LET w(i+j)=w(i+j)+v1(i)*v2(j) !¾ö¤ß¹þ¤ß
NEXT j
NEXT i
IF poly_degree(w)>N THEN CALL Error("¥ª¡¼¥Ð¡¼¥Õ¥í¡¼")
FOR i=0 TO N !²¼n·å¤ò¥³¥Ô¡¼¤¹¤ë
LET v(i)=w(i)
NEXT i
END SUB
EXTERNAL SUB op_div(v1(),v2(), v()) !½ü»»
DIM Q(0 TO UBOUND(v)),R(0 TO UBOUND(v))
IF poly_degree(v2)=0 AND v2(0)=0 THEN !Äê¿ô¤Î£°¤Ê¤é
CALL Error("£°¤Ç¤Ï³ä¤ì¤Þ¤»¤ó¡£")
EXIT SUB
END IF
CALL poly_div(v1,v2, Q,R)
MAT v=Q !¾¦¡¡¢¨v=INT(v1/v2)¤ËÁêÅö
END SUB
EXTERNAL SUB op_pow(v1(),v2(), v()) !¤Ù¤»»
DIM x(0 TO UBOUND(v)),T(0 TO UBOUND(v))
MAT x=v1 !x=v1
MAT T=ZER !Äê¿ô£±
LET T(0)=1
IF poly_degree(v1)=0 THEN !Äê¿ô¹à¤Î¤ß¡ÊÄê¿ô¡Ë
IF poly_degree(v2)>0 THEN CALL Error("¤Ù¤¿ô¤ÏÀ°¿ô¤Î¤ß")
IF errNo<>0 THEN EXIT SUB
IF v1(0)=0 AND v2(0)<0 THEN CALL Error("£°¤ÎÉé¤Ù¤¾è")
IF errNo<>0 THEN EXIT SUB
LET v(0)=v1(0)^v2(0)
ELSE
IF poly_degree(v2)>0 OR v2(0)<0 THEN CALL Error("¤Ù¤¿ô¤ÏÈóÉéÀ°¿ô¤Î¤ß")
IF errNo<>0 THEN EXIT SUB
LET m=v2(0)
DO UNTIL m=0
IF MOD(m,2)=1 THEN CALL op_mul(T,x, T) !¥Ó¥Ã¥È¤¬£±¤Ê¤é¡¢T=T*x
IF errNo<>0 THEN EXIT SUB
CALL op_mul(x,x, x) !x=x^2
IF errNo<>0 THEN EXIT SUB
LET m=INT(m/2) !£²¿Ê¿ô¤Ë¤¹¤ë
LOOP
MAT v=T
END IF
END SUB
EXTERNAL SUB set_fnc(c,v1(), v()) !´Ø¿ô¡ÊÃ͡ˤòÀßÄꤹ¤ë¡¡¢¨°ú¿ô£±¸Ä
!³ºÅö´Ø¿ô¤Ê¤·
END SUB
EXTERNAL SUB set_fnc2(c,v1(),v2(), v()) !´Ø¿ô¡ÊÃ͡ˤòÀßÄꤹ¤ë¡¡¢¨°ú¿ô£²¸Ä
LET N=UBOUND(v)
DIM Q(0 TO N),R(0 TO N),A(0 TO N),B(0 TO N)
SELECT CASE c !³Æ´Ø¿ô¤Ë±þ¤¸¤Æ
CASE 2 !modinv
PRINT "modinv´Ø¿ô¤Ï̤¥µ¥Ý¡¼¥È¡ª"
CASE 3 !¾ê;
CALL poly_div(v1,v2, Q,R)
MAT v=R !;¤ê
CASE 4,5 !ºÇÂç¸øÌó¿ô¡¢ºÇ¾®¸øÇÜ¿ô
MAT A=v1
MAT B=v2
DO UNTIL poly_degree(B)=0 AND B(0)=0 !b=0
CALL poly_div(A,B, Q,R) !R=MOD(a,b)
MAT A=B !a=b
MAT B=R !b=R
LOOP
IF c=5 THEN !LCM=v1*v2/GCD(v1,v2)
CALL op_div(v1,A, Q)
IF errNo<>0 THEN EXIT SUB
CALL op_mul(Q,v2, v)
ELSE !GCD
MAT v=A
END IF
CASE ELSE
END SELECT
END SUB
EXTERNAL SUB set_fnc3(c,v1(),v2(),v3(), v()) !´Ø¿ô¡ÊÃ͡ˤòÀßÄꤹ¤ë¡¡¢¨°ú¿ô£³¸Ä
PRINT "modpow´Ø¿ô¤Ï̤¥µ¥Ý¡¼¥È¡ª"
END SUB
EXTERNAL SUB set_var(c, v()) !ÊÑ¿ô¡ÊÃÍ¡Ë
MAT v=ZER
LET v(1)=1 !x^1¤Î·¸¿ô
END SUB
EXTERNAL SUB set_number(c, v()) !Äê¿ô¡Ê¿ôÃÍ¡Ë
MAT v=ZER
LET v(0)=c !x^0¤Î·¸¿ô
END SUB
END MODULE
!Êä½õ¥ë¡¼¥Á¥ó
!±é»»´ØÏ¢
EXTERNAL SUB poly_div(A(),B(), Q(),R()) !½ü»»¡¡¢¨Èï½ü¿ô=¾¦*½ü¿ô+;¤ê
DIM w(0 TO UBOUND(A))
LET aa=poly_degree(A)
LET bb=poly_degree(B)
MAT Q=ZER !¾¦¡¢¤½¤Î¼¡¿ô
LET qq=MAX(aa-bb,0)
MAT R=A !;¤ê¡¢¤½¤Î¼¡¿ô
LET rr=aa
DO WHILE rr>=bb !Èï½ü¿ô¤Î¼¡¿ô¤¬½ü¿ô¤Î¤è¤êÂ礤¤¤Ê¤é
IF R(rr)<>0 THEN !·¸¿ô¤¬£°°Ê³°¤Ê¤é
LET k=R(rr)/B(bb) !¾¦¤Î·¸¿ô
LET Q(rr-bb)=k !¾¦
MAT w=ZER !;¤ê
FOR i=bb TO 0 STEP -1 !R=A-k*B¡¡¢¨É®»»»²¾È
LET w(rr-bb+i)=k*B(i)
NEXT i
MAT R=R-w
END IF
LET rr=rr-1 !¼¡¤Î¼¡¿ô¤Ø
LOOP
END SUB
EXTERNAL FUNCTION poly_degree(v()) !¼¡¿ô¤òÆÀ¤ë
FOR i=UBOUND(v) TO 1 STEP -1
IF v(i)<>0 THEN EXIT FOR !·¸¿ô¤¬£°¤Ç¤Ê¤¤ºÇ½é¤Î°ÌÃÖ
NEXT i
LET poly_degree=i
END FUNCTION
!ɽ¼¨´ØÏ¢
EXTERNAL SUB poly_disp(A()) !¿¹à¼°¤òɽ¼¨¤¹¤ë¡¡a(X)=¦²AkX^k=AnX^n+An-1X^n-1+¡Ä+A1X+A0
LET aa=poly_degree(A) !ºÇ½é¤Î¹à
CALL mono_disp(A(aa),aa)
FOR i=aa-1 TO 0 STEP -1 !¼¡¹à
LET w=A(i)
IF w>0 THEN PRINT "+";
IF w<>0 OR (w=0 AND aa=0) THEN CALL mono_disp(w,i)
NEXT i
END SUB
EXTERNAL SUB mono_disp(ak,k) !ñ¹à¼°¤òɽ¼¨¤¹¤ë¡¡Ak*X^k
IF k<>0 THEN !x^n¤Ç
IF ak=1 THEN !·¸¿ô¤¬£±¤Ê¤é
ELSEIF ak=-1 THEN !·¸¿ô¤¬¡Ý£±¤Ê¤é
PRINT "-";
ELSE
PRINT STR$(ak);"*";
END IF
END IF
IF k=0 THEN !¼¡¿ô¤¬£°¤Ê¤é
PRINT STR$(ak);
ELSEIF k=1 THEN !¼¡¿ô¤¬£±¤Ê¤é
PRINT "X";
ELSE
PRINT "X^";STR$(k);
END IF
END SUB
!¡¡i3 µÕÊý¸þ¤Î¡¢º¹¤·Âؤ¨Éôʬ(¡¡º¸Ã¼!¤ò³°¤·¤Æ»ÈÍÑ¡£¡Ë
! LET A(1,1)= R1+1/COMPLEX(0,¦Ø*C1)
! LET A(1,2)=-1/COMPLEX(0,¦Ø*C1)
! LET A(1,3)= 0
! LET A(2,1)=-1/COMPLEX(0,¦Ø*C1)
! LET A(2,2)= 1/COMPLEX(0,¦Ø*C1)+R2+R3+1/COMPLEX(0,¦Ø*C3)
! LET A(2,3)=-R3-1/COMPLEX(0,¦Ø*C3)
! LET A(3,1)= 0
! LET A(3,2)=-R3-1/COMPLEX(0,¦Ø*C3)+K/COMPLEX(0,¦Ø*C3)
! LET A(3,3)= 1/COMPLEX(0,¦Ø*C2)+R3+1/COMPLEX(0,¦Ø*C3)-K/COMPLEX(0,¦Ø*C3)
! !
! LET Vin=1
! LET B(1,1)=Vin
! LET B(2,1)=0
! LET B(3,1)=0
! !
! MAT T=INV(A)
! MAT IOUT=T*B
! !
! LET Af=K*((IOUT(2,1)-IOUT(3,1))/COMPLEX(0,¦Ø*C3))/Vin
!¤³¤³¤Þ¤Ç
!
SET TEXT BACKGROUND "OPAQUE"
OPTION ARITHMETIC COMPLEX
LET N=3
DIM A(N),Xr(N)
!
LET R=12E3 !¦¸
LET C=0.0033E-6 !£Æ
LET RC=R*C
!------------------
!¡¡£ú¡¡£ù¡¡¤Çɽ¼¨¤¹¤ë¡Ê »³Ãæ»á¤Î£³£Ä¥×¥í¥Ã¥È£Ó£Õ£Â¡Ë
!¡¡¨¢¡¿
!¡¡¡¦¨¡£ø
!------------------
SUB rotx(x,y,z,a)
LET w=y*COS(a)-z*SIN(a)
LET z=y*SIN(a)+z*COS(a)
LET y=w
END SUB
SUB rotz(x,y,z,a)
LET w=x*COS(a)-y*SIN(a)
LET y=x*SIN(a)+y*COS(a)
LET x=w
END SUB
SUB plots(x,y,z)
CALL rotz(x,y,z,-PI/2.5)
CALL rotx(x,y,z,-PI/10)
PLOT LINES:x,y;
END SUB
SUB plott(x,y,z,w$)
CALL rotz(x,y,z,-PI/2.5)
CALL rotx(x,y,z,-PI/10)
PLOT TEXT,AT x,y:w$
END SUB
!------------------
SET WINDOW -4.2,3.7, -3.6,4.3
!-----
! ÌÜÀ¹¤ê
FOR x=-2 TO 1
IF x=0 THEN SET LINE STYLE 1 ELSE SET LINE STYLE 3
CALL plots((x),-3, 0)
CALL plots((x),+3, 0) !¡¡(x) ¤Ï¡¢SUB ¤«¤é£ø¤Î½ñ¤Ìᤷ¤ÎËɻߡ£
PLOT LINES
CALL plott(x-.1, -3.7, 0, USING$("######",x*5000) )
NEXT x
FOR y=-3 TO 3
IF y=0 THEN SET LINE STYLE 1 ELSE SET LINE STYLE 3
CALL plots(-2,(y), 0)
CALL plots( 1,(y), 0)
PLOT LINES
CALL plott(1.3, y-.3, 0, STR$(y*5000)&"j" )
CALL plott(1.6, y-.4, 0, USING$("#####",y*5000/(2*PI))&"Hz" )
NEXT y
SET LINE STYLE 1
!----
SET LINE COLOR 1
CALL plots(-2,0,0)
CALL plots(-2,0,4)
PLOT LINES
CALL plott(-2, 0.1, 1.5, "K=0.90" )
CALL plott(-2, 0.1, 2.5, "K=0.95" )
CALL plott(-2, 0.1, 3.5, "K=1.0" )
!
!-----
! K ¤Èº¬¤Î¥°¥é¥Õ
LET rss=15 ! Gv=10~100000 10ÇÜËè¤Î¥¹¥Æ¥Ã¥×¿ô
FOR p=0 TO 4*rss
LET Gv=10^(1+p/rss)
LET K=Gv/(1+Gv)
!
LET A(1)=6*(1-K)/RC
LET A(2)=5*(1-K)/RC^2
LET A(3)=(1-K)/RC^3
CALL DKA_00
!
PRINT USING "Gv=###### K=.#####": Gv,K;
FOR s=1 TO 3
PRINT USING"¨#####.# #####.#Hz" :re(Xr(s)),im(Xr(s))/(2*PI);
SET LINE COLOR s+1
CALL plots(re(Xr(s))/5000,im(Xr(s))/5000, 0)
CALL plots(re(Xr(s))/5000,im(Xr(s))/5000,(K-0.8)*20)
PLOT LINES
NEXT s
PRINT
NEXT p
! Xr( 1 ~ n ) <== root
!--------------------------------------------
SUB DKA_00
LET r=1
FOR j=2 TO N
LET rn=ABS(A(j))^(1/j)
if r<rn then LET r=rn
NEXT j
FOR j=1 TO N
LET Xr(j)=-A(1)/N+r*EXP( complex(0,1)*2*PI/N *(j-3/4) )
NEXT j
FOR m=0 TO 100
LET mfx=0
LET maj=0
FOR j=1 TO N
LET Xk=1
LET fx=1
FOR w=1 TO N
LET fx=fx*Xr(j)+A(w)
IF w<>j THEN LET Xk=Xk*(Xr(j)-Xr(w))
NEXT w
LET Xr(j)=Xr(j)-fx/Xk
IF mfx<ABS(fx) THEN LET mfx=ABS(fx)
IF maj<ABS(fx/Xk) THEN LET maj=ABS(fx/Xk)
NEXT j
IF mfx<.0000001 AND maj<.0000001 THEN EXIT FOR
NEXT m
END SUB
LET N=4 !¼¡¿ô
DIM A(0 TO N) !¿¹à¼°¤Î·¸¿ô A(n)*s^n+A(n-1)*s^(n-1)+ ¡Ä +A(1)*s+A(0)¡¢A(n)>0
DATA 1,5,10,10,4 !s^4+5*s^3+10*s^2+10*s+4
FOR i=N TO 0 STEP -1
READ A(i) !·¸¿ô¤òÆɤ߹þ¤à
IF A(i)<=0 THEN !¤¹¤Ù¤ÆÀµ¤«¤É¤¦¤«³Îǧ¤¹¤ë
PRINT "°ÂÄê¤Ê¿¹à¼°¤Ç¤Ê¤¤¡£"
STOP
END IF
NEXT i
!¥é¥¦¥¹É½¤ò¤Ä¤¯¤ë
!£±¹Ô¡¡B1¡¡A(N) A(N-2) A(N-4) ¡Ä
!£²¹Ô¡¡B2¡¡A(N-1) A(N-3) A(N-5) ¡Ä¡¡¡¡¢ª B1
!£³¹Ô¡¡B3¡¡¢ª B2
! ¡§ ¡¡¡¡¡¡¢ª B3
! ¡§
LET M=INT(N/2)
DIM B1(0 TO M),B2(0 TO M),B3(0 TO M)
FOR i=0 TO N !£°¹ÔÌÜ¡¢£±¹ÔÌÜ
IF MOD(i,2)=0 THEN LET B1(INT(i/2))=A(N-i) ELSE LET B2(INT(i/2))=A(N-i)
NEXT i
MAT PRINT B1; !debug
MAT PRINT B2;
FOR l=2 TO N !£²¹ÔÌÜ¡Á£Î¹ÔÌÜ
MAT B3=ZER
FOR i=0 TO M-1
LET B3(i)=-1/B2(0)*( B1(0)*B2(i+1) - B1(i+1)*B2(0) )
NEXT i
MAT PRINT B3; !debug
IF B3(0)<=0 THEN !¥é¥¦¥¹¿ôÎ󤬤¹¤Ù¤ÆÀµ¤«¤É¤¦¤«³Îǧ¤¹¤ë
PRINT "°ÂÄê¤Ê¿¹à¼°¤Ç¤Ê¤¤¡£"
STOP
END IF
MAT B1=B2
MAT B2=B3
NEXT l
PRINT "°ÂÄê¤Ê¿¹à¼°¤Ç¤¢¤ë¡£"
END
¡ü¥Õ¥ë¥Ó¥Ã¥Ä¡ÊHurwitz¡Ë¤Î°ÂÄêȽÊÌË¡
LET N=4 !¼¡¿ô
DIM A(0 TO N) !¿¹à¼°¤Î·¸¿ô A(n)*s^n+A(n-1)*s^(n-1)+ ¡Ä +A(1)*s+A(0)
DATA 1,5,10,10,4 !s^4+5*s^3+10*s^2+10*s+4
FOR i=N TO 0 STEP -1
READ A(i) !·¸¿ô¤òÆɤ߹þ¤à
IF A(i)<=0 THEN !¤¹¤Ù¤ÆÀµ¤«¤É¤¦¤«³Îǧ¤¹¤ë
PRINT "°ÂÄê¤Ê¿¹à¼°¤Ç¤Ê¤¤¡£"
STOP
END IF
NEXT i
!¥Õ¥ë¥Ó¥Ã¥Ä¹ÔÎó¼°¤ò¤Ä¤¯¤ë
!¨¢A(n-1) A(n-3) A(n-5) ¡Ä 0 ¨¢
!¨¢A(n) ¡¡A(n-2) A(n-4) ¡Ä 0 ¨¢
!¨¢0¡¡¡¡¡¡A(n-1) A(n-3) ¡Ä 0 ¨¢
!¨¢0¡¡¡¡¡¡A(n) ¡¡A(n-2) ¡Ä 0 ¨¢
!¡¡¡¡¡§
!¡¡¡¡¡§
!¨¢0¡¡¡¡¡¡0¡¡¡¡¡¡0¡¡¡¡¡Ä A(1)¨¢
DIM B(N,N)
FOR m=1 TO N
MAT B=ZER(m,m)
LET k=N-1
FOR i=1 TO m
FOR j=1 TO m
LET t=k-2*(j-1)
IF t>=0 AND t<=N THEN LET B(i,j)=A(t)
NEXT j
LET k=k+1
NEXT i
MAT PRINT B; !debug
IF DET(B)<=0 THEN
PRINT "ÉÔ°ÂÄê¤Ê¿¹à¼°¤Ç¤¹¡£"
!STOP
END IF
PRINT "¹ÔÎó¼°=";DET(B) !debug
NEXT m
PRINT "°ÂÄê¤Ê¿¹à¼°¤Ç¤¢¤ë¡£"
END
OPTION ARITHMETIC RATIONAL
LET N=20
PRINT fact(N) !¸¡»»
LET A=N
LET S=0 !5¤Î¿ô¤ò¿ô¤¨¤ë
DO UNTIL A=0
LET A=INT(A/5) !5,5^2,5^3,¡Ä¤Ç³ä¤ë
LET S=S+A
LOOP
PRINT S;"¸Ä"
!LET A=N
!LET S=0 !2¤Î¿ô¤ò¿ô¤¨¤ë
!DO UNTIL A=0
! LET A=INT(A/2) !2,2^2,2^3,¡Ä¤Ç³ä¤ë
! LET S=S+A
!LOOP
!PRINT S;"¸Ä"
END
LET N=20
FOR i=2 TO N
IF isPRIME(i)=-1 THEN !ÁÇ¿ô¤ËÂФ·¤Æ
LET a=N
LET s=0 !ÁÇ¿ôi¤Î¸Ä¿ô
DO UNTIL a=0
LET a=INT(a/i)
LET s=s+a
LOOP
PRINT STR$(i);"^";STR$(s) !¤Ù¤¾è¤Çɽ¼¨
END IF
NEXT i
END
!¡üÁÇ¿ô¤«¤É¤¦¤«È½Äꤹ¤ë¡Ê¥¨¥é¥È¥¹¥Æ¥Í¥¹¤Î¤Õ¤ë¤¤Ë¡¡Ë
!¡¡ÊÑ¿ô N¡§ ȽÄꤹ¤ë¿ôÃÍ¡£¢¨£²°Ê¾å
!¡¡´Ø¿ôÃÍ¡§k>0 ÁÇ¿ô¤Ç¤Ê¤¤¡Êk¤ÏÌó¿ô¡Ë¡¢-1 ÁÇ¿ô
EXTERNAL FUNCTION isPRIME(N)
IF MOD(N,2)=0 THEN !2¤Ç³ä¤êÀÚ¤ì¤ë¤Ê¤éÁÇ¿ô¤Ç¤Ê¤¤
LET isPRIME=2
IF N=2 THEN LET isPRIME=-1 !2¤ÏÁÇ¿ô
ELSE
LET isPRIME=-1 !ÁÇ¿ô¤Ç¤¢¤ë
FOR i=3 TO SQR(N) STEP 2 !N¤ÎÊ¿Êýº¬¤Þ¤Ç¤Î´ñ¿ô¤Ç·«¤êÊÖ¤¹
!!!FOR i=3 TO INTSQR(N) STEP 2 !N¤ÎÊ¿Êýº¬¤Þ¤Ç¤Î´ñ¿ô¤Ç·«¤êÊÖ¤¹
IF MOD(N,i)=0 THEN !i¤Ç³ä¤êÀÚ¤ì¤ë¤Ê¤éÁÇ¿ô¤Ç¤Ê¤¤
LET isPRIME=i
EXIT FOR
END IF
NEXT i
END IF
END FUNCTION
¡ü£î¡ª¤Î·×»»
¿ô¤ÎʤӤÎÂоÎÀ¤òÍøÍѤ¹¤ë¡£
! 10!=1*2*3*4*5*6*7*8*9*10¤Î¾ì¹ç
! Ãæ±ûÃÍ¡¡m=6
! 5¤È7¡¡(m-1)*(m+1)=m^2-1=36-1=35¡¢d=1
! 4¤È8¡¡(m-2)*(m+2)=m^2-4=(m^2-1)-3=35-3=32¡¢d=3
! 3¤È9¡¡(m-3)*(m+3)=m^2-9=(m^2-4)-5=32-5=27¡¢d=5
! 2¤È10¡¡(m-4)*(m+4)=m^2-16=(m^2-9)-7=27-7=20¡¢d=7
! 1¡¡Ìµ»ë
! ¡è10!=6*35*32*27*20
LET N=10
LET m=INT(N/2+1) !Ãæ±ûÃÍ
LET s=m
LET mm=m*m
LET d=1
FOR i=1 TO N-m
LET mm=mm-d
LET s=s*mm
LET d=d+2 !1,3,5,7,¡Ä¡¡´ñ¿ô
NEXT i
PRINT s
END
!Parabola Mandala¡Ê´ö²¿³Ø¥¢¡¼¥È¡Ë
OPTION ANGLE DEGREES
SUB circle(a,b,r)
FOR t=0 TO 360
PLOT LINES: a+r*COS(t),b+r*SIN(t);
NEXT t
PLOT LINES
END SUB
DEF f(x)=x^2-x
LET c=(2*SQR(2))
LET d=(12*SQR(2))/5
LET e=(4-c)
LET g=24/5
LET h=(SQR(2)-1)
DIM M(4,4)!¿Þ·Á¤Î΢ÊÖ¤·
MAT READ M
DATA 0, 1, 0, 0
DATA 1, 0, 0, 0
DATA 0, 0, 1, 0
DATA 0, 0, 0, 1
!Lotus Mandala¡Ê±¦Â¦¤ÎÒØè¸Íå¡Ë
SET BITMAP SIZE 800,400
SET WINDOW -6.8,6.8,-6.8,6.8
SET VIEWPORT 0.5,1.0,0,0.5
CALL circle(0,0,c)
CALL circle(d,-d,e)
CALL circle(-d,d,e)
CALL circle(d,d,e)
CALL circle(-d,-d,e)
CALL circle(0,g,e)
CALL circle(0,-g,e)
CALL circle(g,0,e)
CALL circle(-g,0,e)
DRAW nike
DRAW nike WITH ROTATE(90)
DRAW nike WITH ROTATE(180)
DRAW nike WITH ROTATE(270)
DRAW nike WITH M
DRAW nike WITH M*ROTATE(90)
DRAW nike WITH M*ROTATE(180)
DRAW nike WITH M*ROTATE(270)
DRAW pothos WITH SCALE(h)*SHIFT(d,-d)
DRAW pothos WITH SCALE(h)*ROTATE(180)*SHIFT(-d,d)
DRAW pothos WITH SCALE(h)*ROTATE(90)*SHIFT(d,d)
DRAW pothos WITH SCALE(h)*ROTATE(270)*SHIFT(-d,-d)
DRAW pothos WITH M*SCALE(h)*ROTATE(180)*SHIFT(0,g)
DRAW pothos WITH M*SCALE(h)*SHIFT(0,-g)
DRAW pothos WITH M*SCALE(h)*ROTATE(90)*SHIFT(g,0)
DRAW pothos WITH M*SCALE(h)*ROTATE(270)*SHIFT(-g,0)
!Pothos Mandala¡Êº¸Â¦¤ÎÒØè¸Íå¡Ë
SET BITMAP SIZE 800,400
SET WINDOW -6.8,6.8,-6.8,6.8
SET VIEWPORT 0,0.5,0,0.5
CALL circle(0,0,c)
CALL circle(d,-d,e)
CALL circle(-d,d,e)
CALL circle(d,d,e)
CALL circle(-d,-d,e)
CALL circle(0,g,e)
CALL circle(0,-g,e)
CALL circle(g,0,e)
CALL circle(-g,0,e)
DRAW pothos
DRAW pothos WITH SCALE(h)*SHIFT(d,-d)
DRAW pothos WITH SCALE(h)*ROTATE(180)*SHIFT(-d,d)
DRAW pothos WITH SCALE(h)*ROTATE(90)*SHIFT(d,d)
DRAW pothos WITH SCALE(h)*ROTATE(270)*SHIFT(-d,-d)
DRAW pothos WITH M*SCALE(h)*ROTATE(180)*SHIFT(0,g)
DRAW pothos WITH M*SCALE(h)*SHIFT(0,-g)
DRAW pothos WITH M*SCALE(h)*ROTATE(90)*SHIFT(g,0)
DRAW pothos WITH M*SCALE(h)*ROTATE(270)*SHIFT(-g,0)
PICTURE nike
FOR x=0 TO 2 STEP 0.01
PLOT LINES: x,f(x);
NEXT x
FOR x=9/4 TO 1/4 STEP -0.01
PLOT LINES: x-1/4,f(x)-13/16;
NEXT x
END PICTURE
PICTURE pothos
FOR y=-2 TO 1 STEP 0.01
PLOT LINES: -f(ABS(y)),y;
NEXT y
FOR x=-1/4 TO -9/4 STEP -0.01
PLOT LINES: x+1/4,SGN(x)*f(ABS(x))+13/16;
NEXT x
FOR x=-2 TO 2 STEP 0.01
PLOT LINES: x,SGN(x)*f(ABS(x));
NEXT x
END PICTURE
END
!Heart Magic¡Ê´ö²¿³Ø¥¢¡¼¥È¡Ë
OPTION ANGLE DEGREES
DEF f(x)=x^2-x
DEF g(x)=-x^2-x
DEF h(x)=-x^2+1/2*x+1
DEF i(y)=y^2-y
DEF j(y)=y^2+1/2*y-1
DEF k(y)=y^2-1/2*y-1
DEF l(y)=-y^2+1/2*y+1
DIM M(4,4)
MAT READ M !¿Þ·Á¤Î΢ÊÖ¤·
DATA 0, 1, 0, 0
DATA 1, 0, 0, 0
DATA 0, 0, 1, 0
DATA 0, 0, 0, 1
SET WINDOW -9.2,9.2,-9.2,9.2
!½¸¹ç
FOR n=6.9 TO 0 STEP -0.01
SET DRAW mode hidden
CLEAR
DRAW pothos WITH M*ROTATE(180)*SHIFT(0,n)
DRAW pothos WITH M*SHIFT(0,-n)
DRAW pothos WITH M*ROTATE(90)*SHIFT(n,0)
DRAW pothos WITH M*ROTATE(270)*SHIFT(-n,0)
DRAW pothos WITH SHIFT(n,-n)
DRAW pothos WITH ROTATE(180)*SHIFT(-n,n)
DRAW pothos WITH ROTATE(90)*SHIFT(n,n)
DRAW pothos WITH ROTATE(270)*SHIFT(-n,-n)
WAIT DELAY 0.01
SET DRAW mode explicit
NEXT n
WAIT DELAY 8
!ȯ»¶
FOR n=0 TO 6.9 STEP 0.01
SET DRAW mode hidden
CLEAR
DRAW heart1 WITH SHIFT(-n,n)
DRAW heart1 WITH ROTATE(180)*SHIFT(-n/3,n)
DRAW heart1 WITH M*SHIFT(n/3,n)
DRAW heart1 WITH ROTATE(90)*SHIFT(n,n)
DRAW heart2 WITH SHIFT(-n,n/3)
DRAW heart2 WITH ROTATE(180)*SHIFT(-n/3,n/3)
DRAW heart2 WITH ROTATE(90)*SHIFT(n/3,n/3)
DRAW heart2 WITH ROTATE(270)*SHIFT(n,n/3)
DRAW heart3 WITH SHIFT(-n,-n/3)
DRAW heart3 WITH ROTATE(180)*SHIFT(-n/3,-n/3)
DRAW heart3 WITH ROTATE(90)*SHIFT(n/3,-n/3)
DRAW heart3 WITH ROTATE(270)*SHIFT(n,-n/3)
DRAW heart3 WITH M*ROTATE(180)*SHIFT(-n,-n)
DRAW heart3 WITH M*SHIFT(-n/3,-n)
DRAW heart3 WITH M*ROTATE(90)*SHIFT(n/3,-n)
DRAW heart3 WITH M*ROTATE(270)*SHIFT(n,-n)
WAIT DELAY 0.01
SET DRAW mode explicit
NEXT n
PICTURE heart1
FOR x=-1 TO 1 STEP 0.01
PLOT LINES: x,f(ABS(x));
NEXT x
FOR y=0 TO (1+SQR(17))/4 STEP 0.01
PLOT LINES: l(y),y;
NEXT y
FOR y=(1+SQR(17))/4 TO 0 STEP -0.01
PLOT LINES: k(y),y;
NEXT y
END PICTURE
PICTURE heart2
FOR x=-1 TO 0 STEP 0.01
PLOT LINES: x,g(x);
NEXT x
FOR y=0 TO 1 STEP 0.01
PLOT LINES: i(y),y;
NEXT y
FOR x=0 TO 2 STEP 0.01
PLOT LINES: x,h(x);
NEXT x
FOR y=-2 TO 0 STEP 0.01
PLOT LINES: j(y),y;
NEXT y
END PICTURE
PICTURE heart3
FOR y=-2 TO 1 STEP 0.01
PLOT LINES: -f(ABS(y)),y;
NEXT y
FOR x=-1/4 TO -9/4 STEP -0.01
PLOT LINES: x+1/4,SGN(x)*f(ABS(x))+13/16;
NEXT x
END PICTURE
PICTURE pothos
FOR y=-2 TO 1 STEP 0.01
PLOT LINES: -f(ABS(y)),y;
NEXT y
FOR x=-1/4 TO -9/4 STEP -0.01
PLOT LINES: x+1/4,SGN(x)*f(ABS(x))+13/16;
NEXT x
FOR x=-2 TO 2 STEP 0.01
PLOT LINES: x,SGN(x)*f(ABS(x));
NEXT x
END PICTURE
END
SUB SetWindowPos( handle,C2, x0,y0,xw,yw, nFLG ) ! nFLG: 0=x0y0xwyw 1=x0y0 2=xwyw
ASSIGN "user32.dll","SetWindowPos"
END SUB
!----------------------------------------------------------
LET SU=999 !¡¡¥µ¥ó¥×¥ë¤Î¥Ç¡¼¥¿¡¼¿ô
DIM NO_(SU), VA$(SU) !¡¡¥µ¥ó¥×¥ëÈֹ桢¥½¡¼¥È¤¹¤ë¥µ¥ó¥×¥ë¤ÎÃÍ
DIM stb(SU) !¡¡Æ±Ãͥǡ¼¥¿¡¼½çÈÖ¤ò¡¢°ÂÄê²½¤¹¤ë³ÈÄ¥ÇÛÎó
!
LET u_$=REPEAT$("#",LEN(STR$(SU)))
LET u0$=REPEAT$("%",LEN(STR$(SU)))
SUB PRNdata(w$)
MAT PRINT USING " ¡¿ No: "& REPEAT$(u_$& " ",SU): NO_
MAT PRINT USING w$& " ÃÍ: "& REPEAT$(u_$& " ",SU): VA$
END SUB
SUB Result(w$)
!--- ·ë²Ì¤Î¥×¥ê¥ó¥È
LET t1=TIME-t0
IF t1< 0 THEN LET t1=t1+86400
CALL PRNdata("¥½¡¼¥È¡À")
FOR i=2 TO SU
IF VA$(i-1)>VA$(i) THEN EXIT FOR
NEXT i
IF SU< i THEN PRINT w$& ": ¥½¡¼¥È»þ´Ö¡§";t1;"sec." ELSE PRINT w$& ": Error!"
PRINT
END SUB
!------
!¡¡½ç½ø¤ò°ÂÄê²½¤·¤¿¡¢¥¯¥¤¥Ã¥¯¡¦¥½¡¼¥È
SUB Qsort(L,R)
local i,j
LET i=L
LET j=R
LET v$=VA$((L+R)/2)
LET ss=stb((L+R)/2)
DO
DO WHILE VA$(i)< v$ OR (VA$(i)=v$ AND stb(i)< ss)
LET i=i+1
LOOP
DO WHILE v$< VA$(j) OR (VA$(j)=v$ AND ss< stb(j))
LET j=j-1
LOOP
IF j< i THEN EXIT DO
SWAP NO_(i),NO_(j)
SWAP VA$(i),VA$(j)
SWAP stb(i),stb(j)
LET i=i+1
LET j=j-1
LOOP UNTIL j< i
IF L< j THEN CALL Qsort(L,j)
IF i< R THEN CALL Qsort(i,R)
END SUB
!------
!¡¡Ä̾ï¤Î¥¯¥¤¥Ã¥¯¡¦¥½¡¼¥È(Èæ³ÓÍÑ)
SUB Qsort00(L,R)
local i,j
LET i=L
LET j=R
LET v$=VA$((L+R)/2)
DO
DO WHILE VA$(i)< v$
LET i=i+1
LOOP
DO WHILE v$< VA$(j)
LET j=j-1
LOOP
IF j< i THEN EXIT DO !¡¡Åù¹æÉÕ j<=i ¤Ï¡¢Ë½Áö¡£
SWAP NO_(i),NO_(j)
SWAP VA$(i),VA$(j)
LET i=i+1
LET j=j-1
LOOP UNTIL j< i !¡¡Åù¹æÉÕ j<=i ¤Ï¡¢Ä㮡£
IF L< j THEN CALL Qsort00(L,j)
IF i< R THEN CALL Qsort00(i,R)
END SUB
! ´Ñ¾Þ¥°¥é¥Õ
! µ±¤¯ ¥Þ¥ó¥Ç¥ë¥Ö¥í¡¼¡Ê źÉÕ¥µ¥ó¥×¥ë Complex\mandelbm.bas ¤ÎÃ忧²þÊÑ¡Ë
!
OPTION ARITHMETIC COMPLEX
SET POINT STYLE 1
!
FOR n=0 TO 50
SET COLOR MIX( n) 0
,0 ,n/51 !BLACK =< < BLUE
SET COLOR MIX( 51+n) 0 ,n/51 ,1 !BLUE =< < CYAN
SET COLOR MIX(102+n) 0 ,1 ,1-n/51 !CYAN =< < GREEN
SET COLOR MIX(153+n) n/51,1 ,0 !GREEN =< < YELLOW
SET COLOR MIX(204+n) 1 ,1-n/51,0 !YELLOW =< < RED
NEXT n
!SET COLOR MIX(255) 1,0,0 !=RED
SET COLOR MIX(255) 0.549,0.549,0.561 !=GRAY =default
!
LET XL=-2
LET XR=.8
LET w1=XR-XL
LET w2=w1/2
!
SET WINDOW XL, XR,-w2,w2
ASK PIXEL SIZE(XL,-w2; XR,w2) px,py
!
! ¥Þ¥ó¥Ç¥ë¥Ö¥í¡¼¤Î¦Ì-map
! f(z)=z^2+¦Ì¤ÎÈ¿Éü¤¬Í³¦¤È¤Ê¤ëÊ£ÁÇ¿ô¦Ì¤Î½¸¹ç
! ȯ»¶¤ÎȽÄê¤Ë»ê¤ë¤Þ¤Ç¤Î·«¤êÊÖ¤·²ó¿ô¤Ç¿§Ê¬¤±¡£
!
FOR x=XL TO XR STEP w1/(px-1)
FOR y=0 TO w2 STEP w1/(py-1)
LET z=0
FOR n=1 TO 255
LET z=z^2+COMPLEX(x,y)
IF 2< ABS(z) THEN
IF
n< 64 THEN SET POINT COLOR n*4 ELSE SET POINT COLOR 255
PLOT POINTS :x,y
PLOT POINTS :x,-y
EXIT FOR
END IF
NEXT n
NEXT y
NEXT x
!--------------
pause !°ì»þÄä»ß
SET COLOR MIX(0) 1,1,1
CLEAR
FOR x=XL TO XR STEP w1/(px-1)
FOR y=-w2-w1/(py-1)/2 TO w2 STEP w1/(py-1) !¸Î°Õ¤Ë(x,0)¤òÉÁÅÀ¤Î´Ö¤Ë¶´¤à¡£
LET z=0
FOR n=1 TO 255
LET z=z^2+COMPLEX(x,y)
IF 2< ABS(z) THEN
IF
n< 64 THEN SET POINT COLOR n*4 ELSE SET POINT COLOR 255
PLOT POINTS :x,y !¾å²¼¤ÎÂоݥץí¥Ã¥È¤ò¤·¤Ê¤¤¡£
EXIT FOR
END IF
NEXT n
NEXT y
NEXT x
!ÉÔÅù¼°f(x,y)>0¤ÎÎΰ褬¤Ä¤¯¤ëÌÏÍÍ
!´Ø¿ô¤ÎÄêµÁ f(x,y)=0
LET n=0.25
DEF g(x,y)=COS(PI*y)-n/COS(PI*x) !n=[-1,1]
!LET n=0.2
!DEF g(x,y)=x*y/n-(x^2+y^2)/(COS(2*PI*x)+COS(2*PI*y)) !n=[0.1,1]
!LET n=0.5
!DEF g(x,y)=COS(2*PI*y)-COS(2*PI*(COS(2*n*PI*x)+COS(2*n*PI*y))) !n=[0.1,2]
!LET n=3
!DEF g(x,y)=COS(PI*x*y/n)-(COS(2*PI*x)+COS(2*PI*y)) !n=[0.1,5]
!LET n=0.2
!DEF g(x,y)=n*COS(PI*x*y)-(SIN(2*PI*x)+SIN(2*PI*y)) !n=[-0.5,0.5]
!LET n=25
!DEF g(x,y)=COS(PI*x*y)-COS(n*x*y/(x^2+y^2)) !n=[1,100]
!LET n=25
!DEF g(x,y)=COS(PI*x*y)-x*y*COS(n*x*y/(x^2+y^2)) !n=[1,100]
LET a=-5 !x=[a,b]¡¡¢¨xyºÂɸ¤Îɽ¼¨Îΰè
LET b=5
LET c=a !y=[c,d]
LET d=b
SET WINDOW a,b,c,d !ɽ¼¨Îΰè¤òÀßÄꤹ¤ë
DRAW grid(1,1) !ºÂɸ¤òÉÁ¤¯
ASK PIXEL SIZE (a,c; b,d) w,h !²èÁü¤Î½Ä²£¤ÎÂ礤µ(¥É¥Ã¥Èñ°Ì)¤òÄ´¤Ù¤ë
!¾ò·ï¤òËþ¤¿¤¹Îΰè¤òÉÁ¤¯
SET POINT STYLE 1 !¥É¥Ã¥È·Á¼°
SET POINT COLOR 2
FOR j=1 TO h !²èÌÌÁ´ÂΤòÁöºº¤¹¤ë
LET y=WORLDY(j) !¥É¥Ã¥È¤òxyºÂɸ¤ËÊÑ´¹¤¹¤ë
FOR i=1 TO w
LET x=WORLDX(i)
WHEN EXCEPTION IN
LET z=g(x,y) !´Ø¿ôÃͤò·×»»¤¹¤ë
IF z>0 THEN !Àµ¤ÎÉôʬ¤òÀÚ¤ê¼è¤ë
PLOT POINTS: x,y
END IF
USE !£°³ä¤ê¤Ê¤É¤ÎÎã³°½èÍý
END WHEN
NEXT i
NEXT j
END
BVAL¤ÈBSTR$¤ÏJIS Full BASIC¤Ç¤Ï¼Â»þ´Öµ¡Ç½Ã±°Ì¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¼Â»þ´Öµ¡Ç½¤ò¼ÂÁõ¤·¤è¤¦¤È¤¹¤ë¤ÈÌÌÅݤ¬Â¿¡¹½Ð¤Æ¤¯¤ë¤Î¤ÇÅöÌ̤½¤ÎͽÄê¤Ï¤¢¤ê¤Þ¤»¤ó¡£
¤Ç¤¹¤¬¡¤2¿Ê¿ô¡¤16¿Ê¿ô¤Îɽ¸½¤Ï¤Ç¤¤Ê¤¤¤ÈÉÔÊؤʤΤÇJIS¸ß´¹¤È¤Ê¤ë¤è¤¦¤Ë¤½¤Îµ¡Ç½¤òÍÑ°Õ¤·¤Æ¤¤¤Þ¤¹¡£
Full BASIC¤ÎBVAL(s$,r),BSTR$(n,r)¤Ïr¤ÎÉôʬ¤ò¿ôÃͼ°¤Ç»ØÄê¤Ç¤¤Þ¤¹¤¬¡¤½½¿ÊBASIC¤Ç¤ÏÄê¿ô¤Î¤ß¤Ç¤¹¡£
8¿Ê¤ËÂбþ¤¹¤ë¤Î¤Ï¤µ¤Û¤ÉÆñ¤·¤¯¤Ê¤¤¤Î¤Ç¤¹¤¬¡¤¸½ºß¤ÎPC´Ä¶¤Ç¤½¤ÎɬÍ×À¤ò´¶¤¸¤ë¤³¤È¤¬¤Ê¤¤¤Î¤Ç¾Ê¤¤¤Æ¤¤¤Þ¤¹¡£
SUB div1time(i,j)
!----------¡¡¡¡°Ê¾å¤Îʬ³ä¤ò£±²ó¹Ô¤Ê¤¦¥Ö¥í¥°¥é¥à¡£i=L,j=R ¤Ç³«»Ï¡£
LET v$=VA$((i+j)/2)
DO
DO WHILE VA$(i)< v$
LET i=i+1
LOOP
DO WHILE v$< VA$(j)
LET j=j-1
LOOP
IF j< i THEN EXIT DO !¡¡Åù¹æÉÕ j<=i ¤Ï¡¢ÉÔÎÉ¡£Ï¢Â³¤ÎºÆµ¢¤Ç˽Áö¤¹¤ë¡£
SWAP VA$(i),VA$(j)
LET i=i+1
LET j=j-1
LOOP UNTIL j< i !¡¡Åù¹æÉÕ j<=i ¤Ï¡¢ÉÔŬ¡£Ï¢Â³¤ÎºÆµ¢¤ÇÄ㮡£
!----------
END SUB
!===================
SUB QuickSort(L,R) !¡¡¾å¤ò¡¢Ï¢Â³¤Ë¹Ô¤Ê¤¦¥Ö¥í¥°¥é¥à¡£
local i,j
LET i=L
LET j=R
!----------
!¡¡¾å¤Î¥×¥í¥°¥é¥à("---"¤ÎÆâ¦)¤ò¡¢¥³¥³¤ËÃÖ¤¤¤Æ¡¢
!¡¡ºÆµ¢Åª¤Ë¡¢·«ÊÖ¤·»ÈÍÑ¡£
!----------
CALL div1time(i,j) !¤³¤ì¤Ç¤âÎɤ¤¡£¡ÄºÆµ¢Ê¸¤ÎʬΥ¤Ï¡¢local ÊÑ¿ô¤ËÍÑ¿´!
!----------
IF L< j THEN CALL QuickSort(L,j) !¥Ç¡¼¥¿¡¼¿ô£±¸Ä°Ê²¼( L>=j) ¤Ë¤Ê¤ë¤Þ¤Ç¡£
IF i< R THEN CALL QuickSort(i,R) !¥Ç¡¼¥¿¡¼¿ô£±¸Ä°Ê²¼( i>=R) ¤Ë¤Ê¤ë¤Þ¤Ç¡£
END SUB
!==========================¡¡¾åµ¤ÎÆ°ºî¤Î¡¢¿Þ²ò¥¢¥Ë¥á¡¼¥·¥ç¥ó¡¡============
!LET samp$="079427856083621"
LET samp$="0794278069836215794278560836215806083"
LET L=1
LET R=LEN(samp$)
FOR k=L TO R
LET VA$(k)=samp$(k:k)
NEXT k
!
SET TEXT background "Opaque"
SET TEXT font "£Í£Ó ¥´¥·¥Ã¥¯",11
SET WINDOW -1,40, 30,0
SET LINE width 2
PLOT TEXT,AT 1,1.5:"** ¥¯¥¤¥Ã¥¯¡¦¥½¡¼¥È¤Î¼ê½ç **"
LET s=26
PLOT TEXT,AT 1,s :"²¼Àþ¤ÎÉÕ¤¤¤¿Ê¸»ú¤Ï¡¢L~ R Ãæ±û°ÌÃÖ¤ÇÁª¤Ð¤ì¤¿¡Ö´ð½àÃÍ¡×"
PLOT TEXT,AT 1,s+1 :"¤½¤Î¡Ö´ð½àÃ͡פǡ¢Ê¬³ä¤µ¤ì¤¿²¼¤ÎÃʤο§Ê¬¡¢"
SET COLOR MIX(0) 0,1,1
PLOT TEXT,AT 1,s+2 :"ÀĤϡִð½àÃ͡װʲ¼"
SET COLOR MIX(0) 1,1,0
PLOT TEXT,AT 13,s+2 :"²«¤Ï¡Ö´ð½àÃ͡װʾå"
SET COLOR MIX(0) 1,1,1
PLOT TEXT,AT 25,s+2 :"(̵¿§¡§Ê¬³äÉÔÍס¢³ÎÄê)"
PLOT TEXT,AT 1,s+3 :"ÉÁ²è¤Î½ç½ø¤Ï¡¢ºÆµ¢Ê¸¤È¤·¤Æ¤Î¡¢¼Â¹Ô½ç½ø¤½¤Î¤Þ¤Þ¡£"
LET s=3
!
CALL plotVA(L,R,s,L,R)
CALL GraphQS(L,R)
CALL plotVA(L,R,m+1,L,R)
SUB GraphQS(L,R) !¡¡Ê¬³ä·«ÊÖ¤·¤Î¹½Â¤¤ò¡¢¥°¥é¥Õ¥£¥Ã¥¯¤Ëɽ¼¨¡£
local i,j
LET i=L
LET j=R
LET s=s+1
SET COLOR MIX(0) 1,1,1
PLOT TEXT,AT L,s :"L"
PLOT TEXT,AT R,s :"R"
LET s=s+1
!----------
CALL div1time(i,j) !¢« ËÁƬ¤Î¡Êʬ³ä¤ò£±²ó¹Ô¤Ê¤¦¡¦¡¦¡Ëʸ¤ò¡¢¼ÂºÝ¤Ë»ÈÍÑ¡£
CALL plotVA(L,R,s,i,j)
IF m< s THEN LET m=s
WAIT DELAY .1 !¡¡ÉÁ²è¤Î®¤µ¤ÎÄ´À°¡£
!----------
IF L< j THEN CALL GraphQS(L,j)
IF i< R THEN CALL GraphQS(i,R)
LET s=s-2
END SUB
SUB plotVA(L,R,y,i,j)
FOR x=L TO R
IF L=i AND R=j THEN
SET COLOR MIX(0) .8,.8,.8
!SET COLOR MIX(0) 1,1,1
ELSEIF x<=j THEN
SET COLOR MIX(0) 0,1,1
ELSEIF i<=x THEN
SET COLOR MIX(0) 1,1,0
ELSE
SET COLOR MIX(0) 1,1,1
END IF
PLOT TEXT,AT x,y :VA$(x)
IF L<>j AND ROUND((L+j)/2)=x OR i<>R AND ROUND((i+R)/2)=x THEN
PLOT LINES:x+.2,y;x+.6,y
END IF
NEXT x
END SUB
SUB RungeKutta4_1(t, i1)
LET k1=f1(t, i1)
LET k2=f1(t+dt/2, i1+k1*dt/2)
LET k3=f1(t+dt/2, i1+k2*dt/2)
LET k4=f1(t+dt, i1+k3*dt )
LET i1=i1+(k1+2*k2+2*k3+k4)*dt/6
LET f1_=f1(t, i1)
END SUB
SUB RungeKutta4_2(t, i2)
LET k1=f2(t, i2)
LET k2=f2(t+dt/2, i2+k1*dt/2)
LET k3=f2(t+dt/2, i2+k2*dt/2)
LET k4=f2(t+dt, i2+k3*dt )
LET i2=i2+(k1+2*k2+2*k3+k4)*dt/6
LET f2_=f2(t, i2)
END SUB
!----run
LET t=0
LET w=.5 !13
SET WINDOW -w,w,-w,w
SET LINE width 3
SET COLOR MIX(15) .5,.5,.5
SET TEXT background "OPAQUE"
LET t0=TIME
DO
LET t1=TIME
IF dt=< ABS(t1-t0) THEN
SET DRAW mode hidden
CLEAR
DRAW grid(5,5)
PLOT TEXT,AT w*0.25,w*0.9:"¥Þ¥¦¥¹ ±¦¥Ü¥¿¥ó¤Ç¡¢½ªÎ»¡£"
PLOT TEXT,AT w*0.4,w*0.76,USING"±é»»¥Ô¥Ã¥Á=#.### ÉÃ":dt
PLOT TEXT,AT w*0.4,w*0.69,USING"ÉÁ²è¥Ô¥Ã¥Á=#.### ÉÃ":t1-t0
LET t0=t1
PRINT t;i1;i2;f1_;f2_
!---
PLOT TEXT,AT-w/2.5,i1:"i1"
PLOT TEXT,AT w/2.9,i2:"i2"
PLOT LINES :-w/3,i1;0,i1
PLOT LINES : w/3,i2;0,i2
!---
SET DRAW mode explicit
CALL RungeKutta4_1(t,i1) !¡¡¼¡¤Îi1 ¤Ø¹¹¿·
CALL RungeKutta4_2(t,i2) !¡¡¼¡¤Îi2 ¤Ø¹¹¿·
LET t=t+dt
END IF
WAIT DELAY 0 !¡¡¾ÊÅÅÎϸú²Ì
MOUSE POLL mx,my,mlb,mrb
LOOP UNTIL mrb=1
LET drawTime=0.1 ![s] !ÉÁ²è»þ´Ö¤Ç¡¢frq¡ßdrawTime¥µ¥¤¥¯¥ëʬ¤À¤±ÉÁ²è¤¹¤ë¡£
LET iBairitu=500 !ÅÅήÇÈ·ÁÉÁ²è³ÈÂçÇÜΨ
LET i1_=0 ! i1¤Î½é´üÃÍ
LET i2_=0 ! i2¤Î½é´üÃÍ
LET Vt_=E !ÊÑ°µ´ï°ì¼¡ÅÅ°µVt¤Î½é´üÃÍ
LET t_=0 ! t¤Î½é´üÃÍ
SUB RungeKutta4_1(t_, i1_,i1)
LET k1=f1(t_, i1_)
LET k2=f1(t_+dt/2, i1_+k1*dt/2)
LET k3=f1(t_+dt/2, i1_+k2*dt/2)
LET k4=f1(t_+dt, i1_+k3*dt )
LET i1=i1_+(k1+2*k2+2*k3+k4)*dt/6
LET f1_=f1(t_, i1)
END SUB
SUB RungeKutta4_2(t_, i2_,i2)
LET k1=f2(t_, i2_)
LET k2=f2(t_+dt/2, i2_+k1*dt/2)
LET k3=f2(t_+dt/2, i2_+k2*dt/2)
LET k4=f2(t_+dt, i2_+k3*dt )
LET i2=i2_+(k1+2*k2+2*k3+k4)*dt/6
LET f2_=f2(t_, i2)
END SUB
!----run
LET w=2*PI*frq !¸òή¿®¹æ¤Î³Ñ¼þÇÈ¿ô[rad/s]
LET nmax=drawTime/dt !·×»»ÅÀ¿ô
SET WINDOW -0,drawTime,-15,15
DRAW grid
FOR n=1 TO nmax
LET t=n*dt
CALL RungeKutta4_1(t_,i1_,i1)
CALL RungeKutta4_2(t_,i2_,i2)
LET Vt=E-R1*(1+SIN(w*t))*i1
SET LINE COLOR "red" !ÅÅήi1ÇÈ·ÁÉÁ²è¿§
PLOT LINES:t_,i1_*iBairitu;t,i1*iBairitu
SET LINE COLOR "black" !ÅÅ°µÇÈ·ÁÉÁ²è¿§
PLOT LINES:t_,Vt_;t,Vt
PLOT LINES: t_,0;t,0 !»þ´Ö¼´ÉÁ²è
LET t_=t !¡¡¼¡¤Ît ¤Ø¹¹¿·
LET i1_=i1 !¡¡¼¡¤Îi1 ¤Ø¹¹¿·
LET i2_=i2 !¡¡¼¡¤Îi2 ¤Ø¹¹¿·
LET Vt_=Vt !¡¡¼¡¤Îi2 ¤Ø¹¹¿·
Next N
LET E=10
LET R1=10000
LET ketugo=0.8 !·ë¹ç·¸¿ô¤Ç¡¢1¤Ë¶á¤Å¤±¤ë¤ÈÇÈ·Á¤¬±ÔÍø¤Ë¤Ê¤êȯ¿¶¤¹¤ë
LET L1=0.2
LET L2=0.1
LET R2=2
LET frq=10000 !¿®¹æ¼þÇÈ¿ô[Hz]
LET ndiv=5000 !£±¥µ¥¤¥¯¥ë¤Î·×»»Ê¬³ä¿ô
LET drawHz=10 ! 1²èÌ̤Çɽ¼¨¤¹¤ë¥µ¥¤¥¯¥ë¿ô[Hz]
LET pass_gamen=1 !½é´ü²áÅÏ»þ¤ÎÉÁ²èÌ̤ò¥Ñ¥¹¤¹¤ë²ó¿ô
LET iBairitu=1000 !ÅÅήÇÈ·ÁÉÁ²è³ÈÂçÇÜΨ¡£1000¤Ç1ÌÜÀ¹¤ê1[mA]¤Ë¤Ê¤ë
LET nmax=drawHz*ndiv !1²èÌ̤ÎÉÁ²èÅÀ¿ô
LET dt=1/frq/ndiv !·×»»Èùʬ»þ´Ö[s]
LET M=ketugo*SQR(L1*L2)
LET w=2*PI*frq !¸òήÀµ¸¹ÇÈ¿®¹æ¤Î³Ñ¼þÇÈ¿ô[rad/s]
LET i1_=0 ! i1¤Î½é´üÃÍ
LET i2_=0 ! i2¤Î½é´üÃÍ
LET Vt_=0 !ÊÑ°µ´ï°ì¼¡ÅÅ°µVt¤Î½é´üÃÍ
LET t_=0 ! t¤Î½é´üÃÍ
!----run
SET WINDOW -0,nmax,-2*E,2*E
DRAW grid
FOR nn=0 TO pass_gamen
FOR n=0 TO nmax
IF n=0 THEN LET xn_=0
LET t=n*dt
LET xn=n
CALL RungeKutta4_1(t_,i1_,i1)
CALL RungeKutta4_2(t_,i2_,i2)
LET Vt=E-R1*(1+SIN(w*t))*i1
IF nn=pass_gamen THEN
SET LINE COLOR "red" !ÅÅήi1ÇÈ·ÁÉÁ²è¿§
PLOT LINES:xn_,i1_*iBairitu;xn,i1*iBairitu
!SET LINE COLOR "blue" !ÅÅήi2ÇÈ·ÁÉÁ²è¿§
!PLOT LINES:xn_,i2_*iBairitu;xn,i2*iBairitu
SET LINE COLOR "black" !ÅÅ°µÇÈ·ÁÉÁ²è¿§
PLOT LINES:xn_,Vt_;xn,Vt
PLOT LINES: xn_,0;xn,0 !»þ´Ö¼´ÉÁ²è
SET LINE COLOR "green" !ÅÅ°µ¡ÞE[V]¥é¥¤¥ó
PLOT LINES:xn_,-E;xn,-E
PLOT LINES:xn_,E;xn,E
END IF
LET t_=t !¡¡¼¡¤Ît ¤Ø¹¹¿·
LET i1_=i1 !¡¡¼¡¤Îi1 ¤Ø¹¹¿·
LET i2_=i2 !¡¡¼¡¤Îi2 ¤Ø¹¹¿·
LET Vt_=Vt !¡¡¼¡¤ÎVt ¤Ø¹¹¿·
LET xn_=xn
next N
NEXT nn
SUB RungeKutta4_1(t_, i1_,i1)
LET k1=f1(t_, i1_)
LET k2=f1(t_+dt/2, i1_+k1*dt/2)
LET k3=f1(t_+dt/2, i1_+k2*dt/2)
LET k4=f1(t_+dt, i1_+k3*dt )
LET i1=i1_+(k1+2*k2+2*k3+k4)*dt/6
LET f1_=f1(t_, i1)
END SUB
SUB RungeKutta4_2(t_, i2_,i2)
LET k1=f2(t_, i2_)
LET k2=f2(t_+dt/2, i2_+k1*dt/2)
LET k3=f2(t_+dt/2, i2_+k2*dt/2)
LET k4=f2(t_+dt, i2_+k3*dt )
LET i2=i2_+(k1+2*k2+2*k3+k4)*dt/6
LET f2_=f2(t_, i2)
END SUB
SET WINDOW -1,1,-1,1
LET y=2^13 !¤³¤ì°Ê¾å¤«¤é
FOR x=-1 TO 1 STEP 0.001
PLOT POINTS: x,y !OK
!PLOT LINES: x,y; x,y !NG¡¡Ãæ±û¤Ë²£¼ÂÀþ¤¬¸«¤¨¤ë¡£¡¡m=2^22°Ê¾å¤Ê¤é²èÌ̾åü¤Ø
NEXT x
END
FOR bs=101 TO 1201 STEP 100
PRINT "BITMAP SIZE "&STR$(bs)&"¡ß"&STR$(bs)
SET bitmap SIZE bs,bs
10 SET WINDOW 0,800,0,800
SET TEXT HEIGHT 30
FOR w=1 TO 3 ! w=4,5¤Ïw=3¤ÈƱ¤¸µóÆ°
PRINT "LINE WIDTH =";w
FOR j=-32 TO -10
CALL test
NEXT j
FOR j=10 TO 32
CALL test
NEXT j
PRINT
NEXT w
PRINT
NEXT bs
SUB test
CLEAR
PLOT TEXT ,AT 300,560 : "BITMAP SIZE "&STR$(bs)&"¡ß"&STR$(bs)
PLOT TEXT ,AT 300,480 : "w = "&STR$(w)
PLOT TEXT ,AT 300,400 : "j = "&STR$(j)
20 LET m=SGN(j)*2^ABS(j)
30 SET LINE WIDTH w
31 !SET LINE STYLE 2
40 FOR i=1 TO 400
50 PLOT LINES: 0,-m+i; 200,-m+i
60 NEXT i
LET err=0
FOR y=0 TO 800
ASK PIXEL VALUE(1,y) col
IF col=1 THEN LET err=1
NEXT y
IF err=1 THEN
PRINT j;
WAIT DELAY 0.3
END IF
END SUB
70 END
Á´·ë²Ì
BITMAP SIZE 101¡ß101
LINE WIDTH = 1
LINE WIDTH = 2
-32 -31 31 32
LINE WIDTH = 3
-32 -31 31 32
BITMAP SIZE 201¡ß201
LINE WIDTH = 1
LINE WIDTH = 2
-32 -31 -30 30 31 32
LINE WIDTH = 3
-32 -31 -30 30 31 32
BITMAP SIZE 301¡ß301
LINE WIDTH = 1
LINE WIDTH = 2
-32 -31 31 32
LINE WIDTH = 3
-32 -31 31 32
SET WINDOW¤ÇÄêµÁ¤µ¤ì¤ëºÂɸ·Ï¤òGDIºÂɸ·Ï¤È°ìÃפµ¤»¤ë¤¿¤á¤Ë
ASK PIXEL SIZE (0,1;1,0) a,b
LET a=a-1
LET b=b-1
SET WINDOW 0,a,b,0
¤ÇºÂɸ·Ï¤òÄêµÁ¤·¤Æ¤¯¤À¤µ¤¤¡£
Windows¤Ç¤Ï¡¤º¸¾åüºÂɸ¤¬¸¶ÅÀ(0,0)¤Ç¡¤±¦²¼Êý¸þ¤ËºÂɸÃͤ¬Áý²Ã¤·¤Þ¤¹¡£
FOR bs=101 TO 1201 STEP 100
PRINT "BITMAP SIZE "&STR$(bs)&"¡ß"&STR$(bs)
SET bitmap SIZE bs,bs
!SET bitmap SIZE 640,480
ASK PIXEL SIZE (0,1;1,0) a,b
LET a=a-1
LET b=b-1
SET WINDOW 0,a,b,0
!!!10 SET WINDOW 0,800,0,800
SET TEXT HEIGHT 30
FOR w=1 TO 3 ! w=4,5¤Ïw=3¤ÈƱ¤¸µóÆ°
PRINT "LINE WIDTH =";w
FOR j=-32 TO -10
CALL test
NEXT j
FOR j=10 TO 32
CALL test
NEXT j
PRINT
NEXT w
PRINT
NEXT bs
SUB test
CLEAR
PLOT TEXT ,AT 300,560 : "BITMAP SIZE "&STR$(bs)&"¡ß"&STR$(bs)
PLOT TEXT ,AT 300,480 : "w = "&STR$(w)
PLOT TEXT ,AT 300,400 : "j = "&STR$(j)
20 LET m=SGN(j)*2^ABS(j)
30 SET LINE WIDTH w
31 !!!SET LINE STYLE 2
40 FOR i=1 TO 400
50 PLOT LINES: 0,m+i; 200,m+i !º¸Ã¼¤ËȯÀ¸<---------- ¢¨
!52 PLOT LINES: m+i,0; m+i,200 !¾åü<---------- ¢¨
60 NEXT i
LET err=0
FOR y=0 TO 800
ASK PIXEL VALUE(0,y) col !º¸Ã¼<---------- ¢¨
!ASK PIXEL VALUE(y,0) col !¾åü<---------- ¢¨
IF col=1 THEN LET err=1
NEXT y
IF err=1 THEN
PRINT j;
WAIT DELAY 0.3
END IF
END SUB
70 END
Windows XP¤Ç´Ñ»¡¤µ¤ì¤ë¸½¾Ý¤Ï¡¤GDI¤ËÅϤ·¤¿ºÂɸÃͤξå°Ì¡¤²¿¥Ó¥Ã¥È¤«¤ò̵»ë¤·¤Æ½èÍý¤µ¤ì¤Æ¤¤¤ë¤³¤È¤Ç¤¹¡£¤½¤ÎÈϰϤ¬ÌÀ³Î¤Ë¤Ê¤ì¤ÐÂбþ¤Ï²Äǽ¤Ç¤¹¡£
¸½¾õ¤Ï¡¤-2^31¤è¤ê¾®¤µ¤±¤ì¤Ð-2^31¤Ë½ñ¤´¹¤¨¡¤2^31-1¤è¤êÂ礤±¤ì¤Ð2^31-1¤Ë½ñ¤´¹¤¨¤Æ¤¤¤Þ¤¹¡£SDK¤Îµ½Ò¤¬´Ö°ã¤Ã¤Æ¤¤¤ë¤È¤Î¤³¤È¤Ê¤Î¤Ç¡¤¤³¤ì¤ò-2^26¡Á2^26-1¤ÎÈϰϤËÊѤ¨¤ì¤Ð¤¤¤¤¤Î¤À¤í¤¦¤È»×¤¤¤Þ¤¹¡£
Windows Me¤Ç¤âƱÍͤʤΤÀ¤í¤¦¤È»×¤¤¤Þ¤¹¤¬¡¤¾å°Ì¤Î²¿¥Ó¥Ã¥È¤¬Ìµ»ë¤µ¤ì¤ë¤Î¤«¤¬ÌäÂê¤Ç¤¹¡£
OPTION CHARACTER byte
LET w=320
LET h=240
SET BITMAP SIZE w,h !²èÌÌ¥µ¥¤¥º
SET WINDOW 0,w-1,0,h-1 !º¸²¼¤¬¸¶ÅÀ¡£²£¤¬£Ø¡¢½Ä£Ù
LET hWnd=FndWnd("TPaintForm","") !¥¦¥¤¥ó¥É¥¦¥Ï¥ó¥É¥ë¤ò¼èÆÀ¤¹¤ë
LET Rect$=REPEAT$(" ",4*4)
LET n=ClientRect(hWnd, Rect$)
PRINT int32(Rect$,0);int32(Rect$,4);int32(Rect$,8);int32(Rect$,12)
LET n=GetWndRect(hWnd, Rect$)
PRINT int32(Rect$,0);int32(Rect$,4);int32(Rect$,8);int32(Rect$,12)
IF hWnd>0 THEN
LET hDC=GetWndDC(hWnd) !¥Ç¥Ð¥¤¥¹¥³¥ó¥Æ¥¥¹¥È¤ò¼èÆÀ¤¹¤ë
IF hDC>0 THEN
!LET n=SetForeWnd(hWnd)
LET n=Ellipse(hDC,20,20,100,200)
LET m=-2^16 !<-------------------- -2^15¡Á2^15¤Ï£Ï£Ë
LET n=MoveTo(hDC,0,m,0) !
LET n=LineTo(hDC,200,m) !
WAIT DELAY 2
LET n=ReleaseDC(hWnd, hDC) !¥Ç¥Ð¥¤¥¹¥³¥ó¥Æ¥¥¹¥È¤ò³«Êü¤¹¤ë
END IF
END IF
END
!--------------------------------------------------
!
EXTERNAL FUNCTION DWORD$(n)
OPTION CHARACTER byte
LET r=MOD(n,2^8)
LET s$=CHR$(r)
LET n=(n-r)/2^8
LET r=MOD(n,2^8)
LET s$=s$ & CHR$(r)
LET n=(n-r)/2^8
LET r=MOD(n,2^8)
LET s$=s$ & CHR$(r)
LET n=(n-r)/2^8
LET r=MOD(n,2^8)
LET DWORD$=s$ & CHR$(r)
END FUNCTION
EXTERNAL FUNCTION WORD$(n)
OPTION CHARACTER byte
LET r=MOD(n,2^8)
LET s$=CHR$(r)
LET n=(n-r)/2^8
LET r=MOD(n,2^8)
LET WORD$=s$ & CHR$(r)
END FUNCTION
EXTERNAL FUNCTION int32(s$,p)
OPTION CHARACTER byte
LET n=0
FOR i=1 TO 4
LET n=n+256^(i-1)*ORD(s$(p+i:p+i))
NEXT i
IF n<2^31 THEN LET int32=n ELSE LET int32=n-2^32
END FUNCTION
EXTERNAL FUNCTION int16(s$,p)
OPTION CHARACTER byte
LET n=0
FOR i=1 TO 2
LET n=n+256^(i-1)*ORD(s$(p+i:p+i))
NEXT i
IF n<2^15 THEN LET int16=n ELSE LET int16=n-2^16
END FUNCTION
!user32.dll
EXTERNAL FUNCTION CloseWnd(hWnd)
ASSIGN "user32.dll","CloseWindow"
END FUNCTION
EXTERNAL FUNCTION CopyRect(lpDstRect$, lpSrcRect$)
ASSIGN "user32.dll","CopyRect"
END FUNCTION
EXTERNAL FUNCTION FndWnd(lpClassName$, lpWindowName$)
ASSIGN "user32.dll","FindWindowA"
END FUNCTION
EXTERNAL FUNCTION FillRect(hDC, lpRect$, hbr)
ASSIGN "user32.dll","FillRect"
END FUNCTION
EXTERNAL FUNCTION GetActWnd
ASSIGN "user32.dll","GetActiveWindow"
END FUNCTION
EXTERNAL FUNCTION ClientRect(hWnd, lpRect$)
ASSIGN "user32.dll","GetClientRect"
END FUNCTION
EXTERNAL FUNCTION GetForeWnd
ASSIGN "user32.dll","GetForegroundWindow"
END FUNCTION
EXTERNAL FUNCTION GetWndDC(hWnd)
ASSIGN "user32.dll","GetWindowDC"
END FUNCTION
EXTERNAL FUNCTION GetWndRect(hWnd, lpRect$)
ASSIGN "user32.dll","GetWindowRect"
END FUNCTION
EXTERNAL FUNCTION IsWndVisible(hWnd)
ASSIGN "user32.dll","IsWindowVisible"
END FUNCTION
EXTERNAL FUNCTION MoveWnd(hWnd, x, y, cx, cy)
ASSIGN "user32.dll","MoveWindow"
END FUNCTION
EXTERNAL FUNCTION OffsetRect(lpRect$, dx, dy)
ASSIGN "user32.dll","OffsetRect"
END FUNCTION
EXTERNAL FUNCTION ReleaseDC(hWnd, hDC)
ASSIGN "user32.dll","ReleaseDC"
END FUNCTION
EXTERNAL FUNCTION SetActWnd(hWnd)
ASSIGN "user32.dll","SetActiveWindow"
END FUNCTION
EXTERNAL FUNCTION SetForeWnd(hWnd)
ASSIGN "user32.dll","SetForegroundWindow"
END FUNCTION
EXTERNAL FUNCTION SetRect(lpRect$, xLeftRect, yTopRect, xRightRect, yBottomRect)
ASSIGN "user32.dll","SetRect"
END FUNCTION
EXTERNAL FUNCTION SetWndPos(hWnd, hWndInsertAfter, x, y, cx, cy, uFlag)
ASSIGN "user32.dll","SetWindowPos"
END FUNCTION
EXTERNAL FUNCTION SetWndText(hWnd, lpString$)
ASSIGN "user32.dll","SetWindowTextA"
END FUNCTION
EXTERNAL FUNCTION ShowWnd(hWnd, nCmdShow)
ASSIGN "user32.dll","ShowWindow"
END FUNCTION
!gdi32.dll
EXTERNAL FUNCTION SolidBrush(crColor)
ASSIGN "gdi32.dll","CreateSolidBrush"
END FUNCTION
EXTERNAL FUNCTION Ellipse(hDC, nLeftRect, nTopRect, nRightRect, nBottomRect)
ASSIGN "gdi32.dll","Ellipse"
END FUNCTION
EXTERNAL FUNCTION LineTo(hDC, x, y)
ASSIGN "gdi32.dll","LineTo"
END FUNCTION
EXTERNAL FUNCTION MoveTo(hDC, x, y, lpPoint)
ASSIGN "gdi32.dll","MoveToEx"
END FUNCTION
EXTERNAL FUNCTION Rectangle(hDC, nLeftRect, nTopRect, nRightRect, nBottomRect)
ASSIGN "gdi32.dll","Rectangle"
END FUNCTION
OPTION ARITHMETIC NATIVE !CPU¥Ñ¥ï¡¼
SET COLOR MODE "NATIVE"
GLOAD "c:\BASICw32\SAMPLE\ZENKOUJI.JPG" !²èÁü¤òÆɤ߹þ¤à
ASK PIXEL SIZE (0,0; 1,1) w,h !²èÁü¤Î½Ä²£¤ÎÂ礤µ(¥Ô¥¯¥»¥ëñ°Ì)¤òÄ´¤Ù¤ë
DIM p(w,h),q(w,h) !²èÁü¤ÎÂ礤µ¤ËÂбþ¤¹¤ëÇÛÎóÍ×ÁǤòÍÑ°Õ¤¹¤ë
ASK PIXEL ARRAY (0,1) p !²èÁü¤Î³ÆÅÀ¤Î¿§¾ðÊó¤òÇÛÎó¤Ë³ÊǼ¤¹¤ë
PRINT "²èÁü¤ÎÂ礤µ ½Ä:";h;" ²£:";w
!SET BITMAP SIZE w,h !¥¦¥£¥ó¥É¥¦¤ÎÂ礤µ¤ò²èÁü¤Ë¹ç¤ï¤»¤ë
LET R=30 !¤á¤¯¤ê¤ÎȾ·Â¡¡¢¨
LET Dx=20 !¤á¤¯¤ê¤ÎÎÌ¡¡¢¨
LET th=RAD(30) !¤á¤¯¤ê¤ÎÊý¸þ¡¡¢¨
DIM M1(3,3),M2(3,3),M4(3,3),M5(3,3),M7(3,3),M8(3,3)
MAT M1=IDN !²èÁü¤ÎÃæ±û¤ò¸¶ÅÀ¤Ø
LET M1(1,3)=-w/2
LET M1(2,3)=-h/2
MAT M2=IDN !¤á¤¯¤êÊý¸þ¤ò£Ø¼´¤Ë°ìÃפµ¤»¡¢È¾·Â¤ò£±¤È¤¹¤ë
LET M2(1,1)=COS(th)/R
LET M2(1,2)=SIN(th)/R
LET M2(2,1)=-SIN(th)/R
LET M2(2,2)=COS(th)/R
MAT M4=IDN !¤á¤¯¤ê¤ÎÃæ¿´¤ò¸¶ÅÀ¤Ø
LET M4(1,3)=-Dx/R
MAT M5=IDN !INV(M4)
LET M5(1,3)=Dx/R
MAT M7=IDN !INV(M2)
LET M7(1,1)=COS(th)*R
LET M7(1,2)=-SIN(th)*R
LET M7(2,1)=SIN(th)*R
LET M7(2,2)=COS(th)*R
MAT M8=IDN !INV(M1)
LET M8(1,3)=w/2
LET M8(2,3)=h/2
MAT q=ZER !¹õ¿§
!ºÂɸÊÑ´¹ f:(x,y)¢ª(xx,yy)¤ÎµÕÊÑ´¹¤ò¹Í¤¨¤ë
!²¼Â¦¤ÎÉôʬ
DIM t(3)
FOR yy=1 TO h !ÊÑ´¹¸å¤Î²èÁÇ°ÌÃÖ¤ÇÁöºº¤¹¤ë
FOR xx=1 TO w
LET t(1)=xx !ÈóÀþ·ÁÊÑ´¹Á°¤ÎÀþ·ÁÊÑ´¹
LET t(2)=yy
LET t(3)=1
MAT t=M1*t
MAT t=M2*t
MAT t=M4*t
!ÈóÀþ·ÁÊÑ´¹
!²£¤«¤é¸«¤¿¿Þ¡Ê¸ú²Ì¤Î¤«¤«¤ëÊý¸þ¤ò£Ø¼´Êý¸þ¤Ë¤È¤ë¡Ë
!£Ú¼´
!¢¬
!¡¦¢ª £Ø¼´
!¡¡¡¡¡¡¡¡¡¡¡¡»ëÀþ
!¡¡¡¡¡¡¡¡¡¡¡¡ ¢
!¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡x'=1
!¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¨¡¨¡¡¦¡¡¡¡¡¡¡¡ ¾å¦
!¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡À¡¡¡¡¡¡¡¡¢¬
!¡¡¡¡¤á¤¯¤ê¤ÎÃæ¿´ ¢ª * ¡¡¡¦x'=0¡¡--------
!¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¿¡¡¡¡¡¡¡¡¢
!¡¡²èÁÇÌÌ¡¡¨¡¨¡¨¡¨¡¨¡¡¦¡¡¡¡¡¡¡¡ ²¼Â¦
!¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡x'=-1
!
!¡¦²¼Â¦¤È¾å¦¤Î½ç¤Ë£²²ó¤ÎÉÁ²è¤Ç±¢Ì̾õî¤ò¹Ô¤¦
LET op=0 !·×»»¸íº¹¤òÈò¤±¤ë¤¿¤á¸µ¤ÎÃͤò»È¤¦
SELECT CASE t(1) !x'=R*Sin(¦Èz)
CASE IS >=1
LET op=-1 !NOP
CASE IS >=0
LET t(1)=ASIN(ABS(t(1))) !0¡åR*ArcSin(x'/R)¡åR*PI/2
LET op=1 !ÊÑ´¹¤µ¤ì¤¿ºÂɸ¤ò»È¤¦
CASE ELSE !x'
END SELECT
MAT t=M5*t !ÈóÀþ·ÁÊÑ´¹¸å¤ÎÀþ·ÁÊÑ´¹
MAT t=M7*t
MAT t=M8*t
!PRINT xx;yy !debug
!MAT PRINT t;
LET x=INT(t(1)) !¸µ¤Î²èÁǤǤΰÌÃÖ
LET y=INT(t(2))
SELECT CASE op !¸µ¤Î²èÁǤòÆɤ߹þ¤ó¤Ç½ñ¤¹þ¤à
CASE 0
LET q(xx,yy)=p(xx,yy)
CASE 1
IF x<1 OR x>w OR y<1 OR y>h THEN !ÈÏ°ÏÆâ¤Ê¤é
ELSE
LET q(xx,yy)=p(x,y)
END IF
CASE ELSE
END SELECT
NEXT xx
NEXT yy
!MAT PLOT CELLS, IN 0,1; 1,0 :q !²èÁü¤òɽ¼¨¤¹¤ë debug
!STOP
!¾å¦¤ÎÉôʬ¡Ê¤á¤¯¤ê¾å¤¬¤Ã¤Æ΢ÊÖ¤ëÉôʬ¡Ë
FOR yy=1 TO h !ÊÑ´¹¸å¤Î²èÁÇ°ÌÃÖ¤ÇÁöºº¤¹¤ë
FOR xx=1 TO w
LET t(1)=xx !ÈóÀþ·ÁÊÑ´¹Á°¤ÎÀþ·ÁÊÑ´¹
LET t(2)=yy
LET t(3)=1
MAT t=M1*t
MAT t=M2*t
MAT t=M4*t
!ÈóÀþ·ÁÊÑ´¹
!!!¡ü´¬¤¹þ¤Þ¤Ê¤¤¾ì¹ç¤Ï¡¢¤³¤Á¤é
LET op=0 !·×»»¸íº¹¤òÈò¤±¤ë¤¿¤á¸µ¤ÎÃͤò»È¤¦
SELECT CASE t(1)
CASE IS >=1
LET op=-1 !NOP
CASE IS >=0
LET t(1)=PI-ASIN(ABS(t(1))) !R*PI/2¡åR*PI-R*ArcSin(x'/R)¡åR*PI
LET op=1
CASE ELSE
LET t(1)=PI-t(1) !R*PI-x'
LET op=1
END SELECT
!!!¡ü´¬¤¹þ¤à¾ì¹ç¤Ï¡¢¤³¤Á¤é
!!!LET op=0 !·×»»¸íº¹¤òÈò¤±¤ë¤¿¤á¸µ¤ÎÃͤò»È¤¦
!!!SELECT CASE t(1)
!!!CASE IS >=1
!!! LET op=-1 !NOP
!!!CASE IS >=0
!!! LET t(1)=PI-ASIN(ABS(t(1)))
!!! LET op=1
!!!CASE IS >=-1
!!! LET t(1)=PI+ASIN(ABS(t(1)))
!!! LET op=1
!!!CASE ELSE
!!! LET op=-1 !NOP
!!!END SELECT
MAT t=M5*t !ÈóÀþ·ÁÊÑ´¹¸å¤ÎÀþ·ÁÊÑ´¹
MAT t=M7*t
MAT t=M8*t
!PRINT xx;yy !debug
!MAT PRINT t;
LET x=INT(t(1)) !¸µ¤Î²èÁǤǤΰÌÃÖ
LET y=INT(t(2))
SELECT CASE op !¸µ¤Î²èÁǤòÆɤ߹þ¤ó¤Ç½ñ¤¹þ¤à
CASE 0
LET q(xx,yy)=p(xx,yy)
CASE 1
IF x<1 OR x>w OR y<1 OR y>h THEN !ÈÏ°ÏÆâ¤Ê¤é
ELSE
LET q(xx,yy)=p(x,y)
END IF
CASE ELSE
END SELECT
NEXT xx
NEXT yy
MAT PLOT CELLS, IN 0,1; 1,0 :q !²èÁü¤òɽ¼¨¤¹¤ë
END
OPTION ARITHMETIC NATIVE !CPU¥Ñ¥ï¡¼
SET COLOR MODE "NATIVE"
GLOAD "c:\BASICw32\SAMPLE\ZENKOUJI.JPG" !²èÁü¤òÆɤ߹þ¤à
ASK PIXEL SIZE (0,0; 1,1) w,h !²èÁü¤Î½Ä²£¤ÎÂ礤µ(¥Ô¥¯¥»¥ëñ°Ì)¤òÄ´¤Ù¤ë
DIM p(w,h),q(w,h) !²èÁü¤ÎÂ礤µ¤ËÂбþ¤¹¤ëÇÛÎóÍ×ÁǤòÍÑ°Õ¤¹¤ë
ASK PIXEL ARRAY (0,1) p !²èÁü¤Î³ÆÅÀ¤Î¿§¾ðÊó¤òÇÛÎó¤Ë³ÊǼ¤¹¤ë
PRINT "²èÁü¤ÎÂ礤µ ½Ä:";h;" ²£:";w
!SET BITMAP SIZE w,h !¥¦¥£¥ó¥É¥¦¤ÎÂ礤µ¤ò²èÁü¤Ë¹ç¤ï¤»¤ë
LET Rx=100 !µå¤ÎȾ·Â
LET Ry=100
LET Sx=150 !µå¤ÎÃæ¿´
LET Sy=150
LET Tx=w/2+50 !ŽÉÕ¤±°ÌÃÖ
LET Ty=h/2
DIM M1(3,3),M2(3,3),M3(3,3),M6(3,3),M7(3,3),M8(3,3)
MAT M1=IDN !Ãæ¿´¤Î°ÜÆ°
LET M1(1,3)=-Sx
LET M1(2,3)=-Sy
MAT M2=IDN !ÈæΨ¤ÎÊÑ´¹
LET M2(1,1)=1/Rx
LET M2(2,2)=1/Ry
MAT M7=IDN !INV(M2)
LET M7(1,1)=Rx
LET M7(2,2)=Ry
MAT M8=IDN !ŽÉÕ¤±²èÁü¤Î°ÜÆ°
LET M8(1,3)=Tx
LET M8(2,3)=Ty
MAT q=ZER !¹õ¿§
!ºÂɸÊÑ´¹ f:(x,y)¢ª(xx,yy)¤ÎµÕÊÑ´¹¤ò¹Í¤¨¤ë
DIM t(3)
FOR yy=1 TO h !ÊÑ´¹¸å¤Î²èÁÇ°ÌÃÖ¤ÇÁöºº¤¹¤ë
FOR xx=1 TO w
LET t(1)=xx !ÈóÀþ·ÁÊÑ´¹Á°¤ÎÀþ·ÁÊÑ´¹
LET t(2)=yy
LET t(3)=1
MAT t=M1*t
MAT t=M2*t
LET tt=SQR(t(1)*t(1)+t(2)*t(2)) !(x,y)¤Ë±þ¤¸¤Æ²óž¤¹¤ë
IF tt=0 THEN
LET co=0
LET si=0
ELSE
LET co=t(1)/tt
LET si=t(2)/tt
END IF
MAT M3=IDN
LET M3(1,1)=co !£Ø¼´¾å¤Ø¤Î¼ÌÁü
LET M3(1,2)=si
LET M3(2,1)=-si
LET M3(2,2)=co
MAT t=M3*t
!ÈóÀþ·ÁÊÑ´¹
IF t(1)>=0 AND t(1)<1 THEN !µå¤ÎÆâ
LET t(1)=ASIN(t(1)) !ÆÌ
!LET t(1)=ATN(t(1))*1.5 !±ú
LET op=1 !ÊÑ´¹¤µ¤ì¤¿ºÂɸ¤ò»È¤¦
ELSE !µå¤Î³°
LET op=0 !·×»»¸íº¹¤òÈò¤±¤ë¤¿¤á¸µ¤ÎÃͤò»È¤¦
END IF
SELECT CASE op !¸µ¤Î²èÁǤòÆɤ߹þ¤ó¤Ç½ñ¤¹þ¤à
CASE 0
LET q(xx,yy)=p(xx,yy)
CASE 1
MAT M6=IDN !INV(M3) !ÈóÀþ·ÁÊÑ´¹¸å¤ÎÀþ·ÁÊÑ´¹
LET M6(1,1)=co
LET M6(1,2)=-si
LET M6(2,1)=si
LET M6(2,2)=co
MAT t=M6*t
MAT t=M7*t
MAT t=M8*t
!PRINT xx;yy !debug
!MAT PRINT t;
LET x=INT(t(1)) !¸µ¤Î²èÁǤǤΰÌÃÖ
LET y=INT(t(2))
IF x<1 OR x>w OR y<1 OR y>h THEN !ÈÏ°ÏÆâ¤Ê¤é
ELSE
LET q(xx,yy)=p(x,y)
END IF
CASE ELSE !NOP
END SELECT
NEXT xx
NEXT yy
MAT PLOT CELLS, IN 0,1; 1,0 :q !²èÁü¤òɽ¼¨¤¹¤ë
END
¡ü¥â¥¶¥¤¥¯
OPTION ARITHMETIC NATIVE !CPU¥Ñ¥ï¡¼
SET COLOR MODE "NATIVE"
GLOAD "c:\BASICw32\SAMPLE\ZENKOUJI.JPG" !²èÁü¤òÆɤ߹þ¤à
ASK PIXEL SIZE (0,0; 1,1) w,h !²èÁü¤Î½Ä²£¤ÎÂ礤µ(¥Ô¥¯¥»¥ëñ°Ì)¤òÄ´¤Ù¤ë
DIM p(w,h),q(w,h) !²èÁü¤ÎÂ礤µ¤ËÂбþ¤¹¤ëÇÛÎóÍ×ÁǤòÍÑ°Õ¤¹¤ë
ASK PIXEL ARRAY (0,1) p !²èÁü¤Î³ÆÅÀ¤Î¿§¾ðÊó¤òÇÛÎó¤Ë³ÊǼ¤¹¤ë
PRINT "²èÁü¤ÎÂ礤µ ½Ä:";h;" ²£:";w
!SET BITMAP SIZE w,h !¥¦¥£¥ó¥É¥¦¤ÎÂ礤µ¤ò²èÁü¤Ë¹ç¤ï¤»¤ë
LET Rx=10 !£±ÊÕ¤ÎŤµ
LET Ry=10
LET th=RAD(30) !Êý¸þ
DIM M1(3,3),M2(3,3),M7(3,3),M8(3,3)
MAT M1=IDN !²èÁü¤ÎÃæ±û¤ò¸¶ÅÀ¤Ø
LET M1(1,3)=-w/2
LET M1(2,3)=-h/2
MAT M2=IDN !Êý¸þ¤ò£Ø¼´¤Ë°ìÃפµ¤»¡¢È¾·Â¤ò£±¤È¤¹¤ë
LET M2(1,1)=COS(th)/Rx
LET M2(1,2)=SIN(th)/Rx
LET M2(2,1)=-SIN(th)/Ry
LET M2(2,2)=COS(th)/Ry
MAT M7=IDN !INV(M2)
LET M7(1,1)=COS(th)*Rx
LET M7(1,2)=-SIN(th)*Rx
LET M7(2,1)=SIN(th)*Ry
LET M7(2,2)=COS(th)*Ry
MAT M8=IDN !INV(M1)
LET M8(1,3)=w/2
LET M8(2,3)=h/2
MAT q=ZER !¹õ¿§
!ºÂɸÊÑ´¹ f:(x,y)¢ª(xx,yy)¤ÎµÕÊÑ´¹¤ò¹Í¤¨¤ë
DIM t(3)
FOR yy=1 TO h !ÊÑ´¹¸å¤Î²èÁÇ°ÌÃÖ¤ÇÁöºº¤¹¤ë
FOR xx=1 TO w
LET t(1)=xx !ÈóÀþ·ÁÊÑ´¹Á°¤ÎÀþ·ÁÊÑ´¹
LET t(2)=yy
LET t(3)=1
MAT t=M1*t
MAT t=M2*t
!ÈóÀþ·ÁÊÑ´¹
LET t(1)=INT(t(1))+0.5
LET t(2)=INT(t(2))+0.5
MAT t=M7*t !ÈóÀþ·ÁÊÑ´¹¸å¤ÎÀþ·ÁÊÑ´¹
MAT t=M8*t
!PRINT xx;yy !debug
!MAT PRINT t;
LET x=INT(t(1)) !¸µ¤Î²èÁǤǤΰÌÃÖ
LET y=INT(t(2))
IF x<1 OR x>w OR y<1 OR y>h THEN !ÈÏ°ÏÆâ¤Ê¤é
ELSE
LET q(xx,yy)=p(x,y)
END IF
NEXT xx
NEXT yy
MAT PLOT CELLS, IN 0,1; 1,0 :q !²èÁü¤òɽ¼¨¤¹¤ë
END
CALL red_point1
SET BEAM MODE "IMMORTAL"
LET t0=0 ! LET t0=-PI
LET t9=2*PI ! LET t9=PI
FOR t=t0 TO t9+1E-8 STEP (t9-t0)/500
CALL red_point2
WHEN EXCEPTION IN
PLOT LINES : r(t)*COS(t),r(t)*SIN(t);
! PLOT POINTS : r(t)*COS(t),r(t)*SIN(t)
USE
PLOT LINES
END WHEN
WAIT DELAY 0.01
NEXT t
PLOT LINES
SET BEAM MODE "RIGOROUS"
BEEP
PLOT TEXT ,AT (x9+x0)/2,y0 : "¥¯¥ê¥Ã¥¯¤Ç¶ËºÂɸɽ¼¨,±¦¥¯¥ê¥Ã¥¯¤Ç½ªÎ»"
DRAW p_coordinate(2,3) ! ¶ËºÂɸɽ¼¨(ÊгÑÈÏ°Ï(1¡Á2),ɽ¼¨°ÌÃÖ(1¡Á4))
SUB red_point1
IF SGN(x0)<>SGN(x9) THEN LET rx0=0 ELSE LET rx0=MIN(ABS(x0),ABS(x9))
IF SGN(y0)<>SGN(y9) THEN LET ry0=0 ELSE LET ry0=MIN(ABS(y0),ABS(y9))
LET r1=SQR(rx0^2+ry0^2) ! Æ°·ÂºÇ¾®ÃÍ
LET r9=SQR(MAX(ABS(x0),ABS(x9))^2+MAX(ABS(y0),ABS(y9))^2) ! Æ°·ÂºÇÂçÃÍ
LET r8=r1+(r9-r1)/SQR(2) ! ÀÖÅÀ°ÜưȾ·Â
LET x1=r8*COS(t0)
LET y1=r8*SIN(t0)
END SUB
SUB red_point2
LET x2=r8*COS(t)
LET y2=r8*SIN(t)
SET POINT STYLE 3
SET POINT COLOR 0
PLOT POINTS : x1,y1
SET POINT COLOR 4
PLOT POINTS : x2,y2 ! ÀÖÅÀ*
LET x1=x2
LET y1=y2
SET POINT STYLE 1
SET POINT COLOR 1
END SUB
END
REM ¶ËºÂɸ¼´(Æ°·Âɽ¼¨°ÌÃÖ,ÊгÑɽ¼¨ÈÏ°Ï,¼´,Æ°·ÂÌÜÀ¹´Ö³Ö,ÊгÑÌÜÀ¹´Ö³Ö)
EXTERNAL PICTURE polar(rn,tn,ag$,rs,ts)
! rn=Æ°·Âɽ¼¨°ÌÃÖ(0̵,1»ÏÀþ,2½½»ú¾õ,3Êü¼Í¾õ) ; tn=ÊгÑɽ¼¨ÈÏ°Ï(0̵,1[-180¡Á180],2[0¡Á360])
! ag$=¼´("axis"»ÏÀþ¤Î¤ß,"grid"±ßÊü¼Í³Ê»Ò) ; rs=Æ°·ÂÌÜÀ¹´Ö³Ö(>=0) ; ts=ÊгÑÌÜÀ¹´Ö³Ö(0<=ts<360)
ASK LINE COLOR alc
ASK LINE STYLE als
ASK TEXT COLOR atc
ASK TEXT JUSTIFY atjx$,atjy$
ASK AREA COLOR aac
SET LINE COLOR 15
SET TEXT COLOR 15
SET TEXT JUSTIFY "RIGHT","TOP"
ASK WINDOW x0,x9,y0,y9
LET r9=SQR(MAX(ABS(x0),ABS(x9))^2+MAX(ABS(y0),ABS(y9))^2) ! Æ°·ÂºÇÂçÃÍ
IF SGN(x0)<>SGN(x9) THEN LET rx0=0 ELSE LET rx0=MIN(ABS(x0),ABS(x9))
IF SGN(y0)<>SGN(y9) THEN LET ry0=0 ELSE LET ry0=MIN(ABS(y0),ABS(y9))
SET LINE STYLE 1
PLOT LINES : 0,0 ; r9,0 ! ¶ËºÂɸ»ÏÀþ
IF rn>=1 THEN PLOT TEXT ,AT 0,0 : STR$(0)
IF rs>0 THEN ! Æ°·ÂÌÜÀ¹
ASK DEVICE SIZE PX,PY,S$
LET r0=rs*INT(SQR(rx0^2+ry0^2)/rs) ! Æ°·ÂºÇ¾®ÌÜÀ¹
FOR r=r0 TO r9 STEP rs
IF LCASE$(ag$)="axis" OR LCASE$(ag$)="axes" THEN
PLOT LINES : r,-(y9-y0)/PY/2000 ; r,(y9-y0)/PY/2000 ! »ÏÀþÌÜÀ¹
ELSEIF LCASE$(ag$)="grid" THEN
SET LINE STYLE 3
DRAW CIRCLE WITH SHIFT(0,0)*SCALE(r) ! Ʊ¿´±ß
END IF
IF rn=>1 THEN ! Æ°·Â¿ô»ú¤¢¤ê
PLOT TEXT ,AT r,0 : STR$(r) ! »ÏÀþ
IF rn>=2 THEN
PLOT TEXT ,AT 0,r : STR$(r) ! ½½»ú¾õ¾å
PLOT TEXT ,AT -r,0 : STR$(r) ! ½½»ú¾õº¸
PLOT TEXT ,AT 0,-r : STR$(r) ! ½½»ú¾õ²¼
END IF
END IF
NEXT r
END IF
IF ts>0 THEN ! ÊгÑÌÜÀ¹
SET LINE STYLE 3
!FOR t=ts TO 360-ts+1E-6 STEP ts
FOR t=ts TO 360-1E-6 STEP ts
IF LCASE$(ag$)="grid" THEN PLOT LINES : 0,0;r9*COS(RAD(t)),r9*SIN(RAD(t)) ! Êü¼Í¾õÇËÀþ
IF rn=3 THEN ! Æ°·Â¿ô»úÊü¼Í¾õ
FOR r=r0 TO r9 STEP rs
PLOT TEXT ,AT r*COS(RAD(t)),r*SIN(RAD(t)) : STR$(r)
NEXT r
END IF
NEXT t
IF tn>=1 THEN ! Êгѿô»ú¤¢¤ê(ñ°Ì;ÅÙ)
LET r1=SQR(rx0^2+ry0^2) ! Æ°·ÂºÇ¾®ÃÍ
LET r5=(r1+r9)/2 ! Êгѿô»ú°ÌÃÖ
IF rn=3 THEN SET TEXT BACKGROUND "OPAQUE"
!FOR t=ts TO 360-ts+1E-6 STEP ts
FOR t=ts TO 360-1E-6 STEP ts
IF MOD(t,90)<>0 OR rn<=1 OR rs=0 THEN
IF
t<=180 OR tn=2 THEN LET a=t ELSE LET a=t-360 ! a=ÊгÑ
CALL adjust(a)
PLOT TEXT ,AT r5*COS(RAD(t)),r5*SIN(RAD(t)) : STR$(a)
END IF
NEXT t
END IF
END IF
SET TEXT BACKGROUND "TRANSPARENT"
SET LINE COLOR alc
SET LINE STYLE als
SET TEXT COLOR atc
SET TEXT JUSTIFY atjx$,atjy$
SET AREA COLOR aac
SUB adjust(d) ! Êгѿô»ú°ÌÃÖÄ´À°
IF ABS(d)<=67.5 OR d>=292.5 THEN
LET tj1$="LEFT"
ELSEIF ABS(d)>67.5 AND ABS(d)<112.5 OR d>247.5 AND d<292.5 THEN
LET tj1$="CENTER"
ELSE
LET tj1$="RIGHT"
END IF
IF ABS(d)<22.5 OR d>337.5 OR ABS(d)>157.5 AND d<202.5 THEN
LET tj2$="HALF"
ELSEIF d>=22.5 AND d<67.5 OR d>112.5 AND d<=157.5 THEN
LET tj2$="BASE"
ELSEIF d>=67.5 AND d<=112.5 THEN
LET tj2$="BOTTOM"
ELSEIF d>=-112.5 AND d<=-67.5 OR d>=247.5 AND d<=292.5 THEN
LET tj2$="TOP"
ELSE
LET tj2$="CAP"
END IF
SET TEXT JUSTIFY tj1$,tj2$
END SUB
END PICTURE
REM ¶ËºÂɸ(r,¦È)ɽ¼¨
EXTERNAL PICTURE p_coordinate(tn,p)
! ¥Þ¥¦¥¹¥Ý¥¤¥ó¥¿¤¬»Ø¤¹ÅÀ¤Î¶ËºÂɸ(Æ°·Â,ÊгÑ)¤òɽ¼¨
! º¸¥¯¥ê¥Ã¥¯(¥É¥é¥Ã¥°)¤Çɽ¼¨,±¦¥¯¥ê¥Ã¥¯¤Ç½ªÎ»
! tn=ÊгÑÈÏ°Ï(1[-¦Ð<¦È<=¦Ð],2[0<=¦È<2¦Ð]) ; p=ɽ¼¨°ÌÃÖ(1±¦¾å,2º¸¾å,3º¸²¼,4±¦²¼)
ASK WINDOW x0,x9,y0,y9
ASK TEXT JUSTIFY atjx$,atjy$
ASK TEXT HEIGHT ath
ASK AREA COLOR aac
SET TEXT FONT "",10
SET AREA COLOR 0
IF SGN(x0)<>SGN(x9) THEN LET rx0=0 ELSE LET rx0=MIN(ABS(x0),ABS(x9))
IF SGN(y0)<>SGN(y9) THEN LET ry0=0 ELSE LET ry0=MIN(ABS(y0),ABS(y9))
LET r1=SQR(rx0^2+ry0^2) ! Æ°·ÂºÇ¾®ÃÍ
LET r9=SQR(MAX(ABS(x0),ABS(x9))^2+MAX(ABS(y0),ABS(y9))^2) ! Æ°·ÂºÇÂçÃÍ
LET r9d=LOG10(r9)
LET rd=LOG10((r9-r1)/2000)
IF r9d>0 THEN LET u$=REPEAT$("-",CEIL(r9d)-1)&"%" ELSE LET u$="%"
IF rd<0 THEN LET u$=u$&"."&REPEAT$("#",CEIL(ABS(rd)))
CALL position
DO
MOUSE POLL mx,my,ml,mr
IF ml=1 THEN
LET r=SQR(mx^2+my^2) ! Æ°·Â
WHEN EXCEPTION IN
LET t=ANGLE(mx,my) ! ÊгÑ(-¦Ð<t<=¦Ð)
IF tn=2 AND t<0 THEN LET t=t+2*PI ! ÊгÑ(0<=t<2¦Ð)
USE
LET r,t=0 ! ÆðÛÅÀ(¶Ë)
END WHEN
LET
r$=USING$(u$,r)
! Æ°·Â
LET t$=USING$("-%.####",t) ! ÊгÑ
LET d$=USING$("---%.##",DEG(t)) ! (ÅÙ)
PLOT AREA : x1,y1;x2,y1;x2,y2;x1,y2
PLOT TEXT ,AT x1,y1 : r$&" "&t$&"("&d$&"¡ë)"
END IF
WAIT DELAY 0.01 ! CPUÉé²Ù·Ú¸º
LOOP UNTIL mr=1 ! ±¦¥¯¥ê¥Ã¥¯¤Ç½ªÎ»
SET TEXT JUSTIFY atjx$,atjy$
SET TEXT HEIGHT ath
SET AREA COLOR aac
SUB position ! ɽ¼¨°ÌÃÖ
ASK TEXT WIDTH(REPEAT$("W",LEN(u$)+20)) atw
LET x1=x9
LET x2=x9-atw
LET y1=y9
LET y2=y9-1.1*ath
SELECT CASE p
CASE 1 ! ²èÌ̱¦¾å
SET TEXT JUSTIFY "RIGHT","TOP"
CASE 2 ! ²èÌ̺¸¾å
SET TEXT JUSTIFY "LEFT","TOP"
LET x1=x0
LET x2=x0+atw
CASE 3 ! ²èÌ̺¸²¼
SET TEXT JUSTIFY "LEFT","BOTTOM"
LET x1=x0
LET x2=x0+atw
LET y1=y0
LET y2=y0+1.1*ath
CASE 4 ! ²èÌ̱¦²¼
SET TEXT JUSTIFY "RIGHT","BOTTOM"
LET y1=y0
LET y2=y0+1.1*ath
END SELECT
END SUB
END PICTURE
!-------------------------------
LET E=10
LET R1=1000
LET L1=20
LET L2=20
LET R2=1000
LET M=SQR(L1*L2) !·ë¹ç·¸¿ô k=1
!
LET b=1
LET w=2*PI*1 !1Hz
DEF r(t)=R1*(b+SIN(w*t))
!
IF laplace_ON=1 THEN
LET R1=30
LET R2=1e9
END IF
!
!-----¥ë¥ó¥²¡¦¥¯¥Ã¥¿£±
DEF f1(t,i1)=( E-r(t)*i1+M*f2_ )/L1 ! f2_¡ÄľÀܤÎf2()¤Ï¡¢ÉÔ²Ä
DEF f2(t,i2)=( M*f1_-R2*i2 )/L2 ! f1_¡ÄľÀܤÎf1()¤Ï¡¢ÉÔ²Ä
SUB RungeKutta_1(t,i1,i2)
LET k1=f1(t,i1)
LET k2=f1(t+dt/2, i1+k1*dt/2)
LET k3=f1(t+dt/2, i1+k2*dt/2)
LET k4=f1(t+dt, i1+k3*dt )
LET i1=i1+(k1+2*k2+2*k3+k4)*dt/6
LET f1_=f1(t,i1) ! f1_¡Äf1()¤Î¥Ð¥Ã¥Õ¥¡
!
LET k1=f2(t,i2)
LET k2=f2(t+dt/2, i2+k1*dt/2)
LET k3=f2(t+dt/2, i2+k2*dt/2)
LET k4=f2(t+dt, i2+k3*dt )
LET i2=i2+(k1+2*k2+2*k3+k4)*dt/6
LET f2_=f2(t,i2) ! f2_¡Äf2()¤Î¥Ð¥Ã¥Õ¥¡
END SUB
SUB RungeKutta_2(t,i21)
LET k1=f21(t,i21)
LET k2=f21(t+dt/2, i21+k1*dt/2)
LET k3=f21(t+dt/2, i21+k2*dt/2)
LET k4=f21(t+dt, i21+k3*dt )
LET i21=i21+(k1+2*k2+2*k3+k4)*dt/6
END SUB
!-----¥é¥×¥é¥¹µÕÊÑ´¹
DIM Xr(5)
! xr(0)=0 ¡Äº¬¤Ï£¶¸Ä¡¢£°¤Ï¼«ÌÀ¤Ç°ø¿ôʬ²ò¤«¤é½ü¤¤¤¿¡£
LET Xr(1)=-R1*b/L1
LET Xr(2)=COMPLEX(0,w)
LET Xr(3)=COMPLEX(-R1*b/L1,w)
LET Xr(4)=COMPLEX(0,-w)
LET Xr(5)=COMPLEX(-R1*b/L1,-w)
FOR j=1 TO 5
PRINT Xr(j)
NEXT j
DEF Gs(s)=E/L1*( (s^2+w^2)*((s+R1*b/L1)^2+w^2) -R1/L1*s*w*(2*s+R1*b/L1) )*EXP(s*t)
DEF k_0=Gs(0 )/
(
(0 -Xr(1))*(0 -Xr(2))*(0 -Xr(3))*(0 -Xr(4))*(0 -Xr(5))
)
DEF k_1=Gs(Xr(1))/ (
Xr(1) *(Xr(1)-Xr(2))*(Xr(1)-Xr(3))*(Xr(1)-Xr(4))*(Xr(1)-Xr(5))
)
DEF k_2=Gs(Xr(2))/ (
Xr(2)*(Xr(2)-Xr(1)) *(Xr(2)-Xr(3))*(Xr(2)-Xr(4))*(Xr(2)-Xr(5))
)
DEF k_3=Gs(Xr(3))/ (
Xr(3)*(Xr(3)-Xr(1))*(Xr(3)-Xr(2)) *(Xr(3)-Xr(4))*(Xr(3)-Xr(5))
)
DEF k_4=Gs(Xr(4))/ (
Xr(4)*(Xr(4)-Xr(1))*(Xr(4)-Xr(2))*(Xr(4)-Xr(3)) *(Xr(4)-Xr(5))
)
DEF k_5=Gs(Xr(5))/ (
Xr(5)*(Xr(5)-Xr(1))*(Xr(5)-Xr(2))*(Xr(5)-Xr(3))*(Xr(5)-Xr(4))
)
DEF k0_5=re(k_0+k_1+k_2+k_3+k_4+k_5) !α¿ô¤ÎÏÂ
!-----run
SET TEXT background "OPAQUE"
DIM baki(10),bakv(10) ! drawing channels
!
FOR dt=0.0105 TO 0.000499 STEP -0.001 !±é»»¥Ô¥Ã¥Á sec. pitch time
IF laplace_ON=1 THEN LET dt=.0005
SET DRAW mode hidden
CLEAR
SET DRAW mode explicit
LET t=0 !·×»»³«»Ï sec. calculation start
LET ts=0 !ÉÁ²è³«»Ï sec. drawing start
LET tw=3 !ÉÁ²è»þ´Ö sec. drawing time
LET Vw=28 !¡ÜÌÜÀ¹¾å¸Â(¾å¦¥°¥é¥Õ)£±¤ÎÇÜ¿ô¡¢Volt.Ampere. maximum scale
LET ofs=15 !¡ÜÌÜÀ¹¾å¸Â(²¼Â¦¥°¥é¥Õ)£µ¤ÎÇÜ¿ô¡¢Under_Graph offset !CEIL(Vw/10)*5
!
LET i21= -E/R1 ! ¥ë¥ó¥²¡¦¥¯¥Ã¥¿£² ½é´üÃÍ( i1=i31¢«i21, i2=i20¢«i21+i31) at t=0
LET i1=i31 !¨¤
LET i2=i20 !¨«¥ë¥ó¥²¡¦¥¯¥Ã¥¿£± ½é´üÃÍ! at t=0
LET f2_=f2(t,i2) !¨¥
!
IF laplace_ON=1 THEN LET i21=0
!
SET WINDOW -.06*tw, tw, -Vw,Vw
SET COLOR MIX(15) .5,.5,.5
DRAW grid(1,5)
PLOT TEXT,AT .1,Vw*0.92,USING"·×»»´Ö³Ö=#.###### Éᣡ¡·×»»³«»Ï¸å###.### É䫤é¤ÎÉÁ²è":dt,ts
PLOT TEXT,AT .1,Vw*0.86,USING"¦Ø=#.##rad/s E=##V L1=##H L2=##H k=1 R1=####¦¸ R2=####¦¸":w,E,L1,L2,R1,R2
PLOT TEXT,AT .1,-0.1*Vw:"r(t)="& STR$(R1)& "*("& STR$(b)& "+sin¦Øt)"
DO
IF laplace_ON=1 THEN
!-----¥é¥×¥é¥¹
CALL Grph( "green","i1(x20mA)", K0_5*50, "gray","v1(x1V)", K0_5*r(t) , 8, 0)
ELSE
!-----¥ë¥ó¥²¡¦¥¯¥Ã¥¿£±
CALL Grph(
"blue","i1(x20mA)", i1*50 ,
"red","v1(x1V)",r(t)*i1 ,
1, 0)
CALL Grph( "blue","i1(x20mA)", i1*50 , "red","v1(x1V)", E-(L1*f1_-M*f2_), 2, 0)
CALL Grph(
"blue","i2(x2mA)" ,-i2*500, "red","v2(x1V)",
L2*f2_-M*f1_ , 3, ofs )
CALL Grph(
"blue","i2(x2mA)" ,-i2*500,
"red","v2(x1V)",-R2*i2
, 4, ofs )
CALL RungeKutta_1(t,i1,i2)
END IF
!-----¥ë¥ó¥²¡¦¥¯¥Ã¥¿£²
CALL Grph( "blue","i1(x20mA)",
i31*50 , "red","v1(x1V)", r(t)*i31
, 5, 0)
CALL Grph( "blue","i1(x20mA)", i31*50 , "red","v1(x1V)", E+L1*f21(t,i21), 6, 0)
CALL Grph( "blue","i2(x2mA)"
,-i20*500,
"red","v2(x1V)",-R2*i20
, 7, ofs)
CALL RungeKutta_2(t, i21)
!-----
LET t=t+dt
LOOP UNTIL ts+tw< t
NEXT dt
!-----draw
SUB Grph( icol$,i$,i, vcol$,v$,v, n, ofs)
SET WINDOW -.06*tw, tw, -Vw+ofs, Vw+ofs
IF ts< t THEN
SET LINE COLOR vcol$
PLOT LINES :t-ts-dt, bakv(n); t-ts, v
SET LINE COLOR icol$
PLOT LINES :t-ts-dt, baki(n); t-ts, i
ELSEIF t=ts THEN
SET TEXT COLOR vcol$
PLOT TEXT,AT .1, .17*Vw :v$
SET TEXT COLOR icol$
PLOT TEXT,AT .1, .11*Vw :i$
IF ofs<>0 THEN
SET LINE COLOR 15
PLOT LINES :-.06*tw, 0; tw,0
SET TEXT COLOR 15
ASK PIXEL SIZE (0,0 ;tw,Vw) px,py
FOR j=5*INT((-Vw+ofs)/5+1) TO ofs-1 STEP 5
PLOT TEXT,AT -22*tw/px, j-15*Vw/py, USING"###":j
NEXT j
END IF
SET TEXT COLOR 1
END IF
LET baki(n)=i
LET bakv(n)=v
END SUB
!¥¹¥«¥¤¡¦¥¦¥§¥¤
!-----
DIM Tr(4,4),Mv(4,4),Mp(4,4) !Èï¼ÌÂΰÜÆ°¡¢»ëÅÀ°ÜÆ°¡¢¥×¥í¥¸¥§¥¯¥·¥ç¥óÊÑ´¹
DIM mx(4,4),Xz(4,4),zY(4,4) !ºî¶ÈÍÑ¡¢XY_XzÊÑ´¹¡¢XY_zYÊÑ´¹
MAT Tr=IDN
MAT Mv=IDN
!-----£Ù¼´¢ª£Ú¼´¡¡XYÊ¿ÌÌ¿Þ¢ªXZÊ¿ÌÌ¿Þ
MAT READ Xz
DATA 1,0,0,0
DATA 0,0,1,0 !Xz(2,1)=Z¼´¿åÊ¿·¹¼Ð¡¢Xz(2,2)=Z¼´¿âľ·¹¼Ð
DATA 0,0,0,0
DATA 0,0,0,1 !Xz(4,2)=ÁýÀßYºÂɸ
!-----£Ø¼´¢ª£Ú¼´¡¡XYÊ¿ÌÌ¿Þ¢ªZYÊ¿ÌÌ¿Þ
MAT READ zY
DATA 0,0,1,0 !zY(1,1)=Z¼´¿åÊ¿·¹¼Ð¡¢zY(1,2)=Z¼´¿âľ·¹¼Ð
DATA 0,1,0,0
DATA 0,0,0,0
DATA 0,0,0,1 !zY(4,1)=ÁýÀßXºÂɸ
SET WINDOW -1,1,-1,1 ! ²èÌÌ¥¹¥±¡¼¥ë¤Ç¡¢Åê±Æµ÷ΥĴÀ°¡£
!¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¹ÔÎó¤Ï¡¢£±¤ËÀµµ¬²½¤·¤¿¡£
MAT READ Mp
DATA 1,0,0,0 !(X,Y,Z,1)¢ª(1X,1Y,1Z,1Z)¡¡£³ÎóÌܤÎ1Z ¤Ï̵¸ú¡£
DATA 0,1,0,0 !
DATA 0,0,1,1 !¡¡¡¡¡¡¡¡¡¡¡¡£´ÎóÌܤÎ1Z¢ª ÉÁ²èÇÜΨ=1/1Z ¤Ç ±ó¶á¸ú²Ì¤¹¤ë¡£
DATA 0,0,0,0 !¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡(µ÷Î¥£±¤Ø¤ÎÅê±Æ)
LET v0=15 ! m/s ½é®ÅÙ
LET a=-v0^2/2/298 ! m/s^2 ¸ºÂ®²Ã®ÅÙ, -v0^2/2/°ÜÆ°µ÷Î¥
!
LET t0=TIME !³«»Ï
DO WHILE v(t)>0 !¸ºÂ®¡¢Ää»ß¤¹¤ë¤Þ¤Ç
LET t=TIME-t0 !·Ð²á»þ´Ö¤òÆÀ¤ë
IF t>tb+0.15 THEN
LET tb=t
PRINT USING "»þ´Ö=###.## ®ÅÙ=##.## Áö¹Ôµ÷Î¥=###.##":t,v(t),d(t)
SET DRAW mode hidden !΢¥Ú¡¼¥¸¤Ë½ñ¤¯¡¢¤Á¤é¤Ä¤Ëɻߤγ«»Ï
CALL Animation( d(t)) !°ÌÃÖd(t)¤ÎÁ°ÊýÉÁ²è
SET DRAW mode explicit !΢¥Ú¡¼¥¸¤Îɽ¼¨¡¢¤Á¤é¤Ä¤ËɻߤνªÎ»
END IF
LOOP
PICTURE ·úʪ(x,y,w,h,d1)
!¡¡---´éÌÌ
LET zY(1,1)=d_yaw(i+w/2) !Z¼´¿åÊ¿·¹¼Ð¡¢¥«¡¼¥Ö¤ÎÈùʬ
LET zY(1,2)=0 !d_pitch(i+w/2) !Z¼´¿âľ·¹¼Ð¡¢¥Ô¥Ã¥Á¤ÎÈùʬ
LET zY(4,1)=x !ÁýÀßX¼´
DRAW Á°¸åÌÌ(y,w,h) WITH zY !¸µ¤ÎX¼´¢ªZ¼´
!---ÇØÌÌ
LET zY(4,1)=x+d1 !ÁýÀßX¼´
DRAW Á°¸åÌÌ(y,w,h) WITH zY !¸µ¤ÎX¼´¢ªZ¼´
!---²°¾å
LET Xz(2,1)=d_yaw(i+w/2) !Z¼´¿åÊ¿·¹¼Ð¡¢£ú¼´¥«¡¼¥Ö¤ÎÈùʬ
LET Xz(2,2)=0 !d_pitch(i+w/2) !Z¼´¿âľ·¹¼Ð¡¢£ú¼´¥Ô¥Ã¥Á¤ÎÈùʬ
LET Xz(4,2)=y+h !ÁýÀßY¼´
DRAW ¿åÊ¿ÌÌ(x,w,d1) WITH Xz !¸µ¤ÎY¼´¢ªZ¼´
!---¾²ÌÌ
LET Xz(4,2)=y !ÁýÀßY¼´
DRAW ¿åÊ¿ÌÌ(x,w,d1) WITH Xz !¸µ¤ÎY¼´¢ªZ¼´
!---¦ÌÌ
SET AREA COLOR 22
PLOT AREA:x,y; x+d1,y; x+d1,y+h; x,y+h
END PICTURE
!
PICTURE Á°¸åÌÌ(y,w,h)
SET AREA COLOR 25
PLOT AREA:0,y; w,y; w,y+h; 0,y+h !(Z,Y)ºÂɸ¤È¤·¤ÆÉÁ¤¯¡£
END PICTURE
PICTURE ¿åÊ¿ÌÌ(x,w,d1)
SET AREA COLOR 25 !26
PLOT AREA:x,0; x+d1,0; x+d1,w; x,w !(X,Z)ºÂɸ¤È¤·¤ÆÉÁ¤¯¡£
END PICTURE
PICTURE ¥Ð¥¹Ää(c)
SET AREA COLOR c
PLOT AREA:-0.025,0; 0.025,0; 0.025,2; -0.025,2
DRAW disk WITH SCALE(0.5)*SHIFT(0,2)
PLOT TEXT,AT -.35,1.74,USING ">%%":STR$(i)
END PICTURE
INPUT PROMPT "INPUT FILE PATH =":PT$ !'ÀäÂХѥ¹
IF RIGHT$(PT$,1)<>"\" THEN LET PT$=PT$ & "\"
LET PA$=PT$
LET PT$=PT$ & "*.*" !'¥ï¥¤¥ë¥É¥«¡¼¥É
LET N=FILES(PT$)
IF N > 0 THEN
DIM N$(N),NAME$(N),EXT$(N)
FILE LIST PT$, N$
ELSE
PRINT "No File"
STOP
END IF
FOR I=1 TO N
FILE SPLITNAME(N$(I)) PATH$,NA$,EX$
IF POS(".WAV.WMA.MP3",UCASE$(EX$)) > 0 THEN !'³ÈÄ¥»ÒȽÊÌ
LET NN=NN+1
LET NAME$(NN)=NA$ !'¥ê¥¹¥ÈÅÐÏ¿
LET EXT$(NN)=EX$
END IF
NEXT I
IF NN=0 THEN
PRINT "No File"
STOP
END IF
FOR I=1 TO NN !' ¤»¤¤¤¼¤¤¿ô½½¶ÊÄøÅÙ (1¶Ê3ʬ¡ß100¶Ê=5»þ´Ö !?)
FOR J=I+1 TO NN
IF NAME$(I) > NAME$(J) THEN !'!¾º½ç¤Ë¥½¡¼¥È
SWAP NAME$(I),NAME$(J)
SWAP EXT$(I),EXT$(J)
END IF
NEXT J
NEXT I
PRINT "¥Õ¥¡¥¤¥ë¿ô=";NN
DO
INPUT PROMPT "SAVE FILE NAME=":F$ !'³ÈÄ¥»Ò(.asx) OR (.m3u)¤òÉղ乤뤳¤È
LOOP UNTIL UCASE$(RIGHT$(F$,3))="M3U" OR UCASE$(RIGHT$(F$,3))="ASX"
OPEN #1:NAME F$
SELECT CASE UCASE$(RIGHT$(F$,3))
CASE "M3U"
FOR I=1 TO NN
PRINT #1:PA$;NAME$(I);EXT$(I) !'ÀäÂХѥ¹»ØÄê
NEXT I
CASE "ASX"
PRINT #1:CHR$(60);"asx version = ";CHR$(34);"3.0";CHR$(34);" ";CHR$(62)
FOR I=1 TO NN
PRINT #1:CHR$(9);CHR$(60);"entry";CHR$(62)
PRINT #1:CHR$(9);CHR$(9);CHR$(60);"title";CHR$(62);NAME$(I);CHR$(60);"/title";CHR$(62)
PRINT
#1:CHR$(9);CHR$(9);CHR$(60);"ref href =
";CHR$(34);PA$;NAME$(I);EXT$(I);CHR$(34);" /";CHR$(62)
PRINT #1:CHR$(9);CHR$(60);"/entry";CHR$(62)
NEXT I
PRINT #1:CHR$(60);"/asx";CHR$(62)
END SELECT
CLOSE #1
END
RANDOMIZE
DEF FNF(X, Y) = A * X + B * Y - E
DEF FNG(X, Y) = C * X + D * Y - F
LET A=INT(RND*10)+1
LET B=INT(RND*10)+1
LET C=INT(RND*10)+1
LET D=INT(RND*10)+1
LET E=INT(RND*10)-5
LET F=INT(RND*10)-5
PRINT A;"* X +";B;"* Y=";E
PRINT C;"* X +";D;"* Y=";F
LET XH = 100
LET XL = -XH
DO
LET XM = (XH + XL) / 2
LET YM = (F - C * XM) / D !' G(X,Y)=0 ¤ò Y=GG(X)¤Î·Á¤ËÊÑ·Á¤·¡¢XM¤òÂåÆþ
LET YH = (F - C * XH) / D !' G(X,Y)=0 ¤ò Y=GG(X)¤Î·Á¤ËÊÑ·Á¤·¡¢XH¤òÂåÆþ
IF FNF(XM, YM) * FNF(XH, YH) < 0 THEN LET XL = XM ELSE LET XH = XM
LOOP UNTIL ABS(FNF(XM, YM)) < 1E-8 AND ABS(FNG(XM, YM)) < 1E-8
PRINT "X,Y="; XM; YM
PRINT "X,Y=";(D*E-B*F)/(A*D-B*C);(A*F-C*E)/(A*D-B*C) !'¸¡»»
END
OPTION CHARACTER BYTE
LET X=1/3
PRINT CVS(FLOAT2STR$(X,8,23)) !'float 32bit
PRINT STR2FLOAT(PACKDBL$(X),11,52) !'double 64bit
PRINT STR2FLOAT(FLOAT2STR$(X,15,64),15,64) !'long double 80bit
END
EXTERNAL FUNCTION AND(X,Y)
LET XO=X
LET YO=Y
LET A=1
LET S=0
FOR I=0 TO 31
LET XX=MOD(XO,2)
LET YY=MOD(YO,2)
IF YY+XX=2 THEN LET S=S+A
LET XO=INT(XO/2)
LET YO=INT(YO/2)
LET A=A*2
NEXT I
LET AND=S
END FUNCTION
EXTERNAL FUNCTION CVS(A$)
!'IEEE754 32bit str to float
OPTION CHARACTER BYTE
OPTION BASE 0
DIM B(32)
LET A$=LEFT$(A$,4)
LET K = 0
FOR I = 4 TO 1 STEP -1
LET D$ = MID$(A$, I, 1)
FOR J = 0 TO 7
IF AND(ORD(D$),2 ^ (7 -
J))<>0 THEN LET B(K) = 1 ELSE LET B(K) = 0
LET K = K + 1
NEXT J
NEXT I
FOR I = 1 TO 8
LET E = E + B(I) * 2 ^ (8 - I)
NEXT I
LET E=E-127
FOR I = 9 TO 31
LET S = S + B(I) * 2 ^ (8 - I)
NEXT I
LET X=2^E*(S+1)
IF B(0)=1 THEN LET X=-X
LET CVS=X
END FUNCTION
EXTERNAL FUNCTION MKS$(X)
!'IEEE754 32bit float to str
OPTION CHARACTER BYTE
OPTION BASE 0
DIM B(32)
IF X < 0 THEN LET B(0)=1
IF X<>0 THEN
IF ABS(X) < 1 THEN
DO WHILE 2^(N+1) > ABS(X)
LET N=N-1
LOOP
LET N=N+1
ELSE
DO WHILE 2^(N+1) < ABS(X)
LET N=N+1
LOOP
END IF
LET NN=N
LET N=N+127
FOR I=1 TO 8
IF AND(N,2^(8-I))<>0 THEN LET B(I)=1
NEXT I
LET T=(ABS(X)-2^NN)/2^NN
FOR I=9 TO 31
LET T=T*2
IF T >= 1 THEN
LET B(I)=1
LET T=T-INT(T)
END IF
NEXT I
END IF
LET AA$=CHR$(B(0)*128+B(1)*64+B(2)*32+B(3)*16+B(4)*8+B(5)*4+B(6)*2+B(7))
LET BB$=CHR$(B(8)*128+B(9)*64+B(10)*32+B(11)*16+B(12)*8+B(13)*4+B(14)*2+B(15))
LET CC$=CHR$(B(16)*128+B(17)*64+B(18)*32+B(19)*16+B(20)*8+B(21)*4+B(22)*2+B(23))
LET DD$=CHR$(B(24)*128+B(25)*64+B(26)*32+B(27)*16+B(28)*8+B(29)*4+B(30)*2+B(31))
LET MKS$=DD$ & CC$ & BB$ & AA$
END FUNCTION
EXTERNAL FUNCTION FLOAT2STR$(X,L,M) !'²ÄÊÑÀºÅÙÉâÆ°¾®¿ôÊÑ´¹
!'Éä¹æ(1 bit) »Ø¿ôÉô(L bit) ²¾¿ôÉô(M bit)
OPTION CHARACTER BYTE
OPTION BASE 0
IF MOD(L+M+1,8)<>0 THEN EXIT FUNCTION
DIM B(1+L+M)
IF X < 0 THEN LET B(0)=1
IF X<>0 THEN
IF ABS(X) < 1 THEN
DO WHILE 2^(N+1) > ABS(X)
LET N=N-1
LOOP
LET N=N+1
ELSE
DO WHILE 2^(N+1) < ABS(X)
LET N=N+1
LOOP
END IF
FOR I=1 TO L
IF AND(N+2^(L-1)-1,2^(L-I))<>0 THEN LET B(I)=1
NEXT I
LET T=(ABS(X)-2^N)/2^N
FOR I=1+L TO 1+L+M
LET T=T*2
IF T >= 1 THEN
LET B(I)=1
LET T=T-INT(T)
END IF
NEXT I
END IF
FOR J=0 TO (1+L+M)/8-1
LET AA$=CHR$(B(8*J)*128+B(8*J+1)*64+B(8*J+2)*32+B(8*J+3)*16+B(8*J+4)*8+B(8*J+5)*4+B(8*J+6)*2+B(8*J+7))
& AA$
NEXT J
LET FLOAT2STR$=AA$
END FUNCTION
EXTERNAL FUNCTION STR2FLOAT(A$,N,M)
!'Éä¹æ(1 bit) »Ø¿ôÉô(N bit) ²¾¿ôÉô(M bit)
OPTION CHARACTER BYTE
OPTION BASE 0
IF MOD(N+M+1,8)<>0 THEN EXIT FUNCTION
DIM B(1+N+M)
LET K=0
FOR I=INT((1+N+M)/8) TO 1 STEP -1
LET D$=MID$(A$, I, 1)
FOR J=0 TO 7
IF AND(ORD(D$),2^(7-J))<>0 THEN LET B(K)=1
LET K=K+1
NEXT J
NEXT I
FOR I=1 TO N
LET E=E+B(I)*2^(N-I)
NEXT I
LET E=E-(2^(N-1)-1)
FOR I=1+N TO 1+N+M
LET S=S+B(I)*2^(N-I)
NEXT I
LET X=2^E*(1+S)
IF B(0)=1 THEN LET X=-X
LET STR2FLOAT=X
END FUNCTION
!'TT=1-T
!'(TT+T)^(N-1) N=ÅÀ¤Î¿ô (0 <= T <= 1)
CALL GINIT(640,400)
RANDOMIZE
INPUT PROMPT "ÅÀ¤Î¿ô =": N !' N > 1
DIM X(N), Y(N)
FOR I = 1 TO N
LET X(I) = INT(RND * 640)
LET Y(I) = INT(RND * 400)
CALL CIRCLEFULL (X(I),Y(I),6,I)
NEXT I
FOR T = 0 TO 1 STEP 1 / 256
LET XX = 0
LET YY = 0
LET TT=(1-T)
SELECT CASE N
CASE 2
LET XX = TT*X(1)+T*X(2)
LET YY = TT*Y(1)+T*Y(2)
CASE 3
LET XX = TT^2*X(1)+2*TT*T*X(2)+T^2*X(3)
LET YY = TT^2*Y(1)+2*TT*T*Y(2)+T^2*Y(3)
!'CASE 4
!' LET XX = TT^3*X(1)+3*TT^2*T*X(2)+3*TT*T^2*X(3)+T^3*X(4)
!' LET YY = TT^3*Y(1)+3*TT^2*T*Y(2)+3*TT*T^2*Y(3)+T^3*Y(4)
!'CASE 5
!' LET XX =
TT^4*X(1)+4*TT^3*T*X(2)+6*TT^2*T^2*X(3)+4*TT*T^3*X(4)+T^4*X(5)
!' LET YY =
TT^4*Y(1)+4*TT^3*T*Y(2)+6*TT^2*T^2*Y(3)+4*TT*T^3*Y(4)+T^4*Y(5)
CASE ELSE
FOR I=1 TO N
LET XX=XX+TT^(N-I)*T^(I-1)*X(I)*COMB(N-1,I-1)
LET YY=YY+TT^(N-I)*T^(I-1)*Y(I)*COMB(N-1,I-1)
NEXT I
END SELECT
IF T = 0 THEN
LET XA=XX
LET YA=YY
END IF
CALL LINE(XA,YA,XX,YY,7)
LET XA=XX
LET YA=YY
NEXT T
IF N=4 THEN
SET COLOR 1
PLOT BEZIER: X(1), Y(1) ; X(2), Y(2) ; X(3), Y(3); X(4), Y(4) !'¥é¥¤¥ó¤¬°ìÃפ¹¤ë
END IF
END
EXTERNAL SUB GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
SET WINDOW 0 , XSIZE-1 , YSIZE-1, 0
SET POINT STYLE 1
SET COLOR MIX(0) 0,0,0
SET COLOR MIX(1) 0,0,1
SET COLOR MIX(2) 1,0,0
SET COLOR MIX(3) 1,0,1
SET COLOR MIX(4) 0,1,0
SET COLOR MIX(5) 0,1,1
SET COLOR MIX(6) 1,1,0
SET COLOR MIX(7) 1,1,1
CLEAR
END SUB
EXTERNAL SUB LINE(XS,YS,XE,YE,C)
SET COLOR C
PLOT LINES: XS,YS;XE,YE
END SUB
EXTERNAL SUB CIRCLEFULL (X0, Y0, R, C)
LET X = R
LET D = X
LET Y = 0
DO WHILE X >= Y
CALL LINE (X0 - X, Y0 + Y,X0 + X, Y0 + Y, C)
CALL LINE (X0 - X, Y0 - Y,X0 + X, Y0 - Y, C)
CALL LINE (X0 - Y, Y0 + X,X0 + Y, Y0 + X, C)
CALL LINE (X0 - Y, Y0 - X,X0 + Y, Y0 - X, C)
LET D = D - 2 * Y + 1
LET Y = Y + 1
IF D < 0 THEN
LET D = D + 2 * X - 2
LET X = X - 1
END IF
LOOP
END SUB
RANDOMIZE
LET XSIZE=640 !'²èÁü¥µ¥¤¥º
LET YSIZE=400
CALL GINIT(XSIZE,YSIZE)
LET TH=INT(RND*90)
LET S=SIN(TH*PI/180)
LET C=COS(TH*PI/180)
LET R1=INT(RND*256)
LET R2=INT(RND*256)
LET R3=INT(RND*256)
LET R4=INT(RND*256)
LET G1=INT(RND*256)
LET G2=INT(RND*256)
LET G3=INT(RND*256)
LET G4=INT(RND*256)
LET B1=INT(RND*256)
LET B2=INT(RND*256)
LET B3=INT(RND*256)
LET B4=INT(RND*256)
LET MODE=INT(RND*40)+1
SELECT CASE INT(RND*4)
CASE 0
FOR YY=0 TO YSIZE-1
FOR XX=0 TO XSIZE-1
LET T=(C*XX+S*(YSIZE-YY))/(XSIZE*C+YSIZE*S)
LET RR=INTERPOLANT(MODE,R1,R2,T)
LET GG=INTERPOLANT(MODE,G1,G2,T)
LET BB=INTERPOLANT(MODE,B1,B2,T)
CALL PSET(XX,YY,RR,GG,BB)
NEXT XX
NEXT YY
CASE 1
LET N=INT(RND*7)+3
DIM X(N,N),Y(N),R(N),G(N),B(N)
FOR I=1 TO N
FOR J=1 TO N
LET T=(I-1)/(N-1)
LET X(I,J)=T^(N-J)
NEXT J
NEXT I
MAT X=INV(X)
FOR I=1 TO N
LET Y(I)=INT(RND*256)
NEXT I
MAT R=X*Y !'red¤Î·¸¿ô
FOR I=1 TO N
LET Y(I)=INT(RND*256)
NEXT I
MAT G=X*Y !'green¤Î·¸¿ô
FOR I=1 TO N
LET Y(I)=INT(RND*256)
NEXT I
MAT B=X*Y !'blue¤Î·¸¿ô
FOR YY=0 TO YSIZE-1
FOR XX=0 TO XSIZE-1
LET T=(C*XX+S*(YSIZE-YY))/(XSIZE*C+YSIZE*S)
LET RR=0
LET GG=0
LET BB=0
FOR I=1 TO N !'¿¹à¼°¤Î·×»»
LET RR=RR*T+R(I)
LET GG=GG*T+G(I)
LET BB=BB*T+B(I)
NEXT I
CALL PSET(XX,YY,RR,GG,BB)
NEXT XX
NEXT YY
CASE 2 !'»Í³Ñ·Á
FOR YY=0 TO YSIZE-1
FOR XX=0 TO XSIZE-1
LET RR=RECTCOL(0,0,XSIZE-1,YSIZE-1,R1,R2,R3,R4,XX,YY,MODE)
LET GG=RECTCOL(0,0,XSIZE-1,YSIZE-1,G1,G2,G3,G4,XX,YY,MODE)
LET BB=RECTCOL(0,0,XSIZE-1,YSIZE-1,B1,B2,B3,B4,XX,YY,MODE)
CALL PSET(XX,YY,RR,GG,BB)
NEXT XX
NEXT YY
CASE 3 !'»°³Ñ·Á
LET R5=INT(RND*256)
LET G5=INT(RND*256)
LET B5=INT(RND*256)
LET X1=0
LET Y1=0
LET X2=XSIZE-1
LET Y2=0
LET X3=X2
LET Y3=YSIZE-1
LET X4=0
LET Y4=YSIZE-1
LET X5=INT(XSIZE/2)
LET Y5=INT(YSIZE/2)
FOR YY=0 TO YSIZE-1
FOR XX=0 TO XSIZE-1
IF AREA3(X5,Y5,X1,Y1,X2,Y2,XX,YY)<>0 THEN
LET RR=TRIANGLECOL(X5,Y5,X1,Y1,X2,Y2,R5,R1,R2,XX,YY)
LET GG=TRIANGLECOL(X5,Y5,X1,Y1,X2,Y2,G5,G1,G2,XX,YY)
LET BB=TRIANGLECOL(X5,Y5,X1,Y1,X2,Y2,B5,B1,B2,XX,YY)
ELSEIF AREA3(X5,Y5,X2,Y2,X3,Y3,XX,YY)<>0 THEN
LET RR=TRIANGLECOL(X5,Y5,X2,Y2,X3,Y3,R5,R2,R3,XX,YY)
LET GG=TRIANGLECOL(X5,Y5,X2,Y2,X3,Y3,G5,G2,G3,XX,YY)
LET BB=TRIANGLECOL(X5,Y5,X2,Y2,X3,Y3,B5,B2,B3,XX,YY)
ELSEIF AREA3(X5,Y5,X3,Y3,X4,Y4,XX,YY)<>0 THEN
LET RR=TRIANGLECOL(X5,Y5,X3,Y3,X4,Y4,R5,R3,R4,XX,YY)
LET GG=TRIANGLECOL(X5,Y5,X3,Y3,X4,Y4,G5,G3,G4,XX,YY)
LET BB=TRIANGLECOL(X5,Y5,X3,Y3,X4,Y4,B5,B3,B4,XX,YY)
ELSEIF AREA3(X5,Y5,X4,Y4,X1,Y1,XX,YY)<>0 THEN
LET RR=TRIANGLECOL(X5,Y5,X4,Y4,X1,Y1,R5,R4,R1,XX,YY)
LET GG=TRIANGLECOL(X5,Y5,X4,Y4,X1,Y1,G5,G4,G1,XX,YY)
LET BB=TRIANGLECOL(X5,Y5,X4,Y4,X1,Y1,B5,B4,B1,XX,YY)
END IF
CALL PSET(XX,YY,RR,GG,BB)
NEXT XX
NEXT YY
END SELECT
END
EXTERNAL SUB GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
SET COLOR MODE "NATIVE"
CLEAR
SET POINT STYLE 1
SET WINDOW 0,XSIZE-1,YSIZE-1,0
END SUB
EXTERNAL SUB PSET(X,Y,R,G,B)
LET RR=MIN(255,MAX(0,INT(R)))
LET GG=MIN(255,MAX(0,INT(G)))
LET BB=MIN(255,MAX(0,INT(B)))
SET COLOR COLORINDEX(RR/255,GG/255,BB/255)
PLOT POINTS: X , Y
END SUB
EXTERNAL FUNCTION RECTCOL(X1,Y1,X2,Y2,C1,C2,C3,C4,X,Y,MODE)
LET P=(X-X1)/(X2-X1)
LET Q=(Y-Y1)/(Y2-Y1)
LET S1=INTERPOLANT(MODE,C1,C2,P)
LET S2=INTERPOLANT(MODE,C3,C4,Q)
LET RECTCOL=INTERPOLANT(MODE,S1,S2,Q)
END FUNCTION
EXTERNAL FUNCTION INTERPOLANT(MODE,A,B,T) !'Êä´Ö¼°
LET T=MIN(1,MAX(0,T))
SELECT CASE MODE
CASE 1
LET V=(1-T)*A+B*T
CASE 2
LET V=(1-T)^2*A+B*T^2
CASE 3
LET V=(1-T)^3*A+B*T^3
CASE 4
LET V=(1-T)^4*A+B*T^4
CASE 5
LET V=(1-T)^5*A+B*T^5
CASE 6
LET V=(1-T^2)*A+B*T^2
CASE 7
LET V=(1-T^3)*A+B*T^3
CASE 8
IF T=1 THEN LET V=B ELSE LET V=SQR(1-T^2)*A+B*T^2
CASE 9
IF T=1 THEN LET V=B ELSE LET V=SQR(1-T^3)*A+B*T^3
CASE 10
IF T=1 THEN LET V=B ELSE LET V=SQR(1-T^2)^3*A+B*T
CASE 11
LET N=1/2
LET M=1/3
IF T=1 THEN LET V=B ELSE LET V=(1-T^M)^N*A+B*T^M
CASE 12
LET V=A*COS(PI/2*T)+B*SIN(PI/2*T)
CASE 13
LET V=A*COS(PI/2*T)^2+B*SIN(PI/2*T)^3
CASE 14
LET V=A*COS(PI/2*T^2)+B*SIN(PI/2*T^2)
CASE 15
LET V=A*(B/A)^T
CASE 16
LET V=A*EXP(T*LOG(B/A))
CASE 17
LET V=A+(B-A)*TAN(PI/4*T)
CASE 18
LET V=A+(B-A)*SIN(PI/2*T)
CASE 19
LET V=A+(B-A)*LOG(T+1)/LOG(2)
CASE 20
LET V=A+(B-A)*LOG(2*T+1)/LOG(3)
CASE 21
LET V=A+(B-A)*LOG((EXP(1)-1)*T+1)
CASE 22
LET V=A+(B-A)*(2^T-1)
CASE 23
LET V=A+(B-A)*ATN(T)*4/PI
CASE 24
IF T=0 THEN LET V=A ELSE LET V=A+(B-A)*LOG(10*T)/LOG(10)
CASE 25
LET V=A+(B-A)*SQR(T)
CASE 26
LET V=A+(B-A)*T^(1/5)
CASE 27
LET V=A+(B-A)*T^10
CASE 28
LET V=A+(B-A)*ATN(T)*4/PI
CASE 29
LET V=A+(B-A)*ASIN(T)*2/PI
CASE 30
LET V=A+(B-A)*SIN(PI/2*T)^COS(PI/2*T)
CASE 31
LET V=A+T-1+ABS(B-A)^T
CASE 32
LET V=A+(B-A)*(1-(1-T)^T)
CASE 33
LET V=A+(B-A)*(1-(1-T)/(1+T^2))
CASE 34
LET V=A+(B-A)*(T*T*T+T*T+T)/(2*T*T+1)
CASE 35
IF T=1 THEN LET V=B ELSE LET V=A+(B-A)*SIN(PI*(1-T))/((1-T)*PI)
CASE 36
LET V=A+(B-A)*(T^3+3*T^2+2*T)/(T^2+2*T+3)
CASE 37
LET V=A+(B-A)*T^3/(T^2+T-1)
CASE 38
LET V=A+(B-A)*(4^T-1)/(2^T+1)
CASE 39
LET V=A+(B-A)*(T+T^2+T^3+T^4+T^5+T^6+T^7)/7
CASE 40
LET V=A+(B-A)*(5^T-1)/4
END SELECT
LET INTERPOLANT=V
END FUNCTION
EXTERNAL FUNCTION AREA3(X1, Y1, X2, Y2, X3, Y3, PX, PY)
LET T = TRIANGLE(X1, Y1, X2, Y2, X3, Y3)
LET A = TRIANGLE(X1, Y1, X2, Y2, PX, PY)
LET B = TRIANGLE(X2, Y2, X3, Y3, PX, PY)
LET C = TRIANGLE(X1, Y1, X3, Y3, PX, PY)
IF ABS(A + B + C - T) < 1 THEN LET AREA3 = -1 ELSE LET AREA3 = 0
END FUNCTION
EXTERNAL FUNCTION TRIANGLE(X1, Y1, X2, Y2, X3, Y3) !'»°³Ñ·Á¤ÎÌÌÀÑ
LET TRIANGLE = ABS(X1 * Y2 + X2 * Y3 + X3 * Y1 - X2 * Y1 - X3 * Y2 - Y3 * X1) / 2
END FUNCTION
EXTERNAL FUNCTION TRIANGLECOL(OX,OY,AX,AY,BX,BY,C1,C2,C3,X,Y)
LET A = AX - OX
LET B = BX - OX
LET C = AY - OY
LET D = BY - OY
LET PX = X - OX
LET PY = Y - OY
LET DET = A * D - B * C
IF DET = 0 THEN
EXIT FUNCTION
END IF
LET S = (D * PX - B * PY) / DET
IF S < 0 THEN
EXIT FUNCTION
END IF
LET T = (A * PY - C * PX) / DET
IF T < 0 THEN
EXIT FUNCTION
END IF
IF S + T <= 1 THEN
LET TRIANGLECOL=(1-S)*(1-T)*C1+S*C2+T*C3
END IF
END FUNCTION
PRINT CDBL$("ABCD£Á£Â£Ã123") !'Ⱦ³Ñ¤òÁ´³Ñʸ»ú¤Ø
PRINT CSNG$("¤¢¤¤¤¦£Á£Â£Ã£Ä£Å123£±£²£³£´") !'Á´³Ñ¤òȾ³Ñʸ»ú¤Ø
FOR I=1 TO 100
PRINT CDBL$(STR$(I) & ":" & NUM2ROMAN$(I))
NEXT I
END
EXTERNAL FUNCTION NUM2ROMAN$(X) !'(¥¢¥é¥Ó¥¢)¿ô»ú to ¥í¡¼¥Þ¿ô»ú(1°Ê¾å4000̤Ëþ)
LET R$=""
IF X < 4000 AND X > 0 THEN
OPTION BASE 0
DIM T$(4,9)
FOR I=1 TO 3
FOR J=1 TO 9
READ T$(I,J)
NEXT J
NEXT I
DATA I,II,III,IV,V,VI,VII,VIII,IX
DATA X,XX,XXX,XL,L,LX,LXX,LXXX,XC
DATA C,CC,CCC,CD,D,DC,DCC,DCCC,CM
FOR J=1 TO 3
READ T$(4,J)
NEXT J
DATA M,MM,MMM,MMMM
LET A$=LTRIM$(STR$(INT(X)))
FOR I=LEN(A$) TO 1 STEP -1
LET J=VAL(MID$(A$,LEN(A$)-I+1,1))
LET R$=R$ & T$(I,J)
NEXT I
END IF
LET NUM2ROMAN$=R$
END FUNCTION
RANDOMIZE
LET NUM$="0123456789"
!' LET NUM$="0123456789abcdef"
DO
INPUT PROMPT "·å¿ô=": N !' 4¡Á5·åÄøÅÙ
LOOP UNTIL LEN(NUM$) >= N
LET T$=NUM$
FOR I = 1 TO N
LET R = INT(RND * LEN(T$))+1 !'Íð¿ô¤Ç1ʸ»ú¤º¤Ä·è¤á¤ë
LET ANS$=ANS$ & MID$(T$,R,1)
LET T$=LEFT$(T$,R-1) & RIGHT$(T$,LEN(T$)-R) !'Áª¤Ð¤ì¤¿¿ô»ú¤Ï¸õÊ䤫¤é¾Ã¤¹
NEXT I
PRINT N;"·å¤Î¿ô»ú¤òÆþÎϤ·¤Æ²¼¤µ¤¤Ž¡ "
PRINT "GIVE UP ¤Ï '*' ¤Ç¤¹Ž¡"
LET COUNT=1
DO
DO
LET FL=0
PRINT COUNT; "²óÌÜ ";
INPUT PROMPT "NUMBER = ": S$
!' LET S$=LCASE$(S$)
IF ANS$ = S$ THEN
PRINT "ÂçÅö¤¿¤ê ¡ª¡ª"
STOP
ELSEIF S$ = "*" THEN
PRINT "Àµ²ò¤Ï"; ANS$; "¤Ç¤·¤¿Ž¡"
STOP
ELSEIF S$ = "/" THEN
IF LEN(SS$)=N AND H > 0 THEN
PRINT "¥Ò¥ó¥È ";
FOR I=1 TO N
IF MID$(SS$,I,1)=MID$(ANS$,I,1) THEN PRINT MID$(ANS$,I,1); ELSE PRINT
"?";
NEXT I
PRINT
LET SS$=""
LET COUNT = COUNT + 1
END IF
LET FL=1
ELSEIF LEN(S$)<>N THEN
PRINT N;"·å¤Î¿ô»ú¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó"
LET FL=1
ELSE
FOR I=1 TO N
IF POS(NUM$,MID$(S$,I,1))=0 THEN
PRINT "̵¸ú¤Êʸ»ú¤¬¤¢¤ê¤Þ¤¹"
LET FL=1
EXIT FOR
END IF
NEXT I
END IF
LOOP UNTIL FL=0
LET H = 0
LET C = 0
FOR I = 1 TO N
IF MID$(S$,I,1) = MID$(ANS$,I,1) THEN LET H = H + 1 !'¿ô»ú¤È°Ì(°ÌÃÖ)¤¬°ìÃ×
FOR J = 1 TO N
IF I <> J AND
MID$(S$,I,1) = MID$(ANS$,J,1) THEN LET C = C + 1
!'¿ô»ú¤Ï°ìÃפ¹¤ë¤¬°Ì(°ÌÃÖ)¤¬°ã¤¦
NEXT J
NEXT I
PRINT "¥Ò¥Ã¥È";H; " ¥Á¥Ã¥×"; C
LET COUNT = COUNT + 1
LET SS$=S$
LOOP
END
OPTION BASE 0
RANDOMIZE
CALL GINIT(300,300)
SET WINDOW 0 , 3 , 3, 0
DIM X(9),Y(9),M(9),K(9,5)
FOR I=1 TO 9
READ X(I),Y(I)
NEXT I
DATA -1,1
DATA 0,1
DATA 1,1
DATA -1,0
DATA 0,0
DATA 1,0
DATA -1,-1
DATA 0,-1
DATA 1,-1
FOR I=1 TO 9
FOR J=1 TO 5
READ K(I,J)
NEXT J
NEXT I
DATA 1,2,4,0,0
DATA 1,2,3,5,0
DATA 2,3,6,0,0
DATA 1,4,7,5,0
DATA 2,4,5,6,8
DATA 3,5,6,9,0
DATA 4,7,8,0,0
DATA 5,7,8,9,0
DATA 6,8,9,0,0
!' LET KAISU=INT(RND*18)+3
INPUT PROMPT "²ó¿ô=":KAISU
DIM ANS(KAISU),UNDO(KAISU)
FOR I=1 TO KAISU
LET N=INT(RND*9)+1
LET ANS(I)=N
CALL MASU(N,1)
NEXT I
CALL DISPLAY
LET L=KAISU
DO
PRINT "»Ä¤ê²ó¿ô=";L
INPUT PROMPT "Number=":T$
IF T$="*" THEN
EXIT DO
ELSEIF T$="/" THEN
IF KK > 0 THEN
CALL MASU(UNDO(KK),1)
LET KK=KK-1
LET L=L+1
END IF
ELSEIF POS("123456789",T$) > 0 THEN
LET TE=VAL(T$)
LET KK=KK+1
LET UNDO(KK)=TE
CALL MASU(TE,-1)
LET L=L-1
END IF
CALL DISPLAY
LOOP UNTIL L=0
FOR I=1 TO 9
IF M(I)=0 THEN LET CHK=CHK+1
NEXT I
SET COLOR 7
CLEAR
IF CHK=9 THEN
SET TEXT HEIGHT 0.32
PLOT TEXT ,AT 0,1.5: "Congratulations"
ELSE
SET TEXT HEIGHT 3/5.6
PLOT TEXT ,AT 0,1.5: "Game Over"
WAIT DELAY 1.5
MAT M=ZER
FOR L=1 TO KAISU
CALL MASU(ANS(L),1)
NEXT L
CALL DISPLAY
WAIT DELAY 2
FOR L=KAISU TO 1 STEP -1
LET N=ANS(L)
PRINT "No.";KAISU-L+1;"Number=";N
CALL MASU(N,-1)
CALL DISPLAY
WAIT DELAY 1
NEXT L
END IF
SUB MASU(TE,C)
FOR J=1 TO 5
LET V=M(K(TE,J))+C
IF V < 0 THEN LET V=7
IF V > 7 THEN LET V=0
LET M(K(TE,J))=V
NEXT J
END SUB
SUB DISPLAY
FOR J=1 TO 9
CALL BOXFULL(X(J)+1,Y(J)+1,X(J)+2,Y(J)+2,M(J))
NEXT J
FOR I=1 TO 2
FOR J=1 TO 2
CALL LINE(I,0,I,3,7)
CALL LINE(0,J,3,J,7)
NEXT J
NEXT I
END SUB
END
EXTERNAL SUB GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
SET POINT STYLE 1
SET COLOR MODE "REGULAR"
SET COLOR MIX(0) 0,0,0
SET COLOR MIX(1) 0,0,1
SET COLOR MIX(2) 1,0,0
SET COLOR MIX(3) 1,0,1
SET COLOR MIX(4) 0,1,0
SET COLOR MIX(5) 0,1,1
SET COLOR MIX(6) 1,1,0
SET COLOR MIX(7) 1,1,1
CLEAR
END SUB
EXTERNAL SUB BOXFULL(X1,Y1,X2,Y2,C)
SET COLOR C
PLOT AREA: X1,Y1;X2,Y1;X2,Y2;X1,Y2;X1,Y1
END SUB
EXTERNAL SUB LINE(XS,YS,XE,YE,C)
SET COLOR C
PLOT LINES
PLOT LINES: XS,YS;XE,YE
END SUB
OPTION BASE 0
RANDOMIZE
!' INPUT PROMPT "SIZE ²£,½Ä=":XSIZE,YSIZE
LET XSIZE=INT(RND*7)+3
LET YSIZE=INT(RND*7)+3
CALL GINIT(80*XSIZE,80*YSIZE)
SET WINDOW 0 , XSIZE , YSIZE, 0
SET TEXT JUSTIFY "LEFT" , "HALF"
FOR I=1 TO XSIZE-1
FOR J=1 TO YSIZE-1
CALL LINE(I,0,I,YSIZE,7)
CALL LINE(0,J,XSIZE,J,7)
NEXT J
NEXT I
LET KAISU=INT(RND*10)+3
!' INPUT PROMPT "²ó¿ô=":KAISU
DIM M(XSIZE,YSIZE),XX(KAISU),YY(KAISU)
DIM UNDOX(KAISU),UNDOY(KAISU)
FOR K=1 TO KAISU
LET X=INT(RND*XSIZE)
LET Y=INT(RND*YSIZE)
LET XX(K)=X
LET YY(K)=Y
CALL MASU(X,Y,1)
NEXT K
CALL DISPLAY
LET L=KAISU
DO
LET FL=0
PRINT "»Ä¤ê²ó¿ô=";L
DO
MOUSE POLL X,Y,LEFT,RIGHT
LOOP WHILE LEFT=1 OR RIGHT=1
DO
MOUSE POLL X,Y,LEFT,RIGHT
IF GETKEYSTATE(27)<0 THEN LET FL=1
LOOP WHILE LEFT=0 AND RIGHT=0 AND FL=0
IF FL=1 THEN EXIT DO
IF RIGHT=1 THEN
IF KK > 0 THEN
LET X=UNDOX(KK)
LET Y=UNDOY(KK)
LET KK=KK-1
CALL MASU(X,Y,1)
CALL DISPLAY
LET L=L+1
END IF
ELSEIF LEFT=1 THEN
LET X=INT(X)
LET Y=INT(Y)
PRINT "X,Y=(";X;",";Y;")"
LET KK=KK+1
LET UNDOX(KK)=X
LET UNDOY(KK)=Y
CALL MASU(X,Y,-1)
LET L=L-1
CALL DISPLAY
END IF
LOOP UNTIL L=0
FOR I=0 TO XSIZE-1
FOR J=0 TO YSIZE-1
IF M(I,J)=0 THEN LET CHK=CHK+1
NEXT J
NEXT I
CLEAR
SET COLOR 7
IF CHK=XSIZE*YSIZE THEN !' ¥²¡¼¥à¥¯¥ê¥¢
SET TEXT HEIGHT XSIZE/9.375
PLOT TEXT ,AT 0,YSIZE/2: "Congratulations"
ELSE
SET TEXT HEIGHT XSIZE/5.6
PLOT TEXT ,AT 0,YSIZE/2: "Game Over"
WAIT DELAY 1.5
MAT M=ZER
FOR K=1 TO KAISU
CALL MASU(XX(K),YY(K),1)
NEXT K
CALL DISPLAY
WAIT DELAY 2
FOR K=KAISU TO 1 STEP -1 !'²òÅú¤Îɽ¼¨
CALL MASU(XX(K),YY(K),-1)
PRINT "No.";KAISU-K+1;" X,Y=(";XX(K);",";YY(K);")"
CALL DISPLAY
WAIT DELAY 1
NEXT K
END IF
SUB MASU(X,Y,C)
FOR I=-1 TO 1
FOR J=-1 TO 1
IF X+I >= 0 AND Y+J
>= 0 AND X+I < XSIZE AND Y+J < YSIZE AND I*J=0 THEN
LET V=M(X+I,Y+J)+C
IF V < 0 THEN LET V=7
IF V > 7 THEN LET V=0
LET M(X+I,Y+J)=V
END IF
NEXT J
NEXT I
END SUB
SUB DISPLAY !'²èÌÌɽ¼¨
FOR I=0 TO XSIZE-1
FOR J=0 TO YSIZE-1
CALL BOXFULL(I,J,I+1,J+1,M(I,J))
NEXT J
NEXT I
FOR I=1 TO XSIZE-1
FOR J=1 TO YSIZE-1
CALL LINE(I,0,I,YSIZE,7)
CALL LINE(0,J,XSIZE,J,7)
NEXT J
NEXT I
END SUB
END
EXTERNAL SUB GINIT(XSIZE,YSIZE)
SET BITMAP SIZE XSIZE,YSIZE
SET POINT STYLE 1
SET COLOR MODE "REGULAR"
SET COLOR MIX(0) 0,0,0
SET COLOR MIX(1) 0,0,1
SET COLOR MIX(2) 1,0,0
SET COLOR MIX(3) 1,0,1
SET COLOR MIX(4) 0,1,0
SET COLOR MIX(5) 0,1,1
SET COLOR MIX(6) 1,1,0
SET COLOR MIX(7) 1,1,1
CLEAR
END SUB
EXTERNAL SUB BOXFULL(X1,Y1,X2,Y2,C)
SET COLOR C
PLOT AREA: X1,Y1;X2,Y1;X2,Y2;X1,Y2;X1,Y1
END SUB
EXTERNAL SUB LINE(XS,YS,XE,YE,C)
SET COLOR C
PLOT LINES
PLOT LINES: XS,YS;XE,YE
END SUB
DECLARE EXTERNAL FUNCTION COMB
PUBLIC NUMERIC MAXSIZE,MSIZE,B(20),EPS
PUBLIC STRING T$(20),TT$(20)
DIM A(20),C(20),TI$(20),TEMP(20) !'¸Ä¿ô¤Ï10¡Á15ÄøÅÙ¤òÁÛÄê
LET N=1
LET EPS=0
LET SUM=0
DO
INPUT PROMPT "¿ôÃÍ(" & STR$(N) & ") ":A(N) !'(¥Õ¥¡¥¤¥ë¥µ¥¤¥º¡¢±éÁÕ»þ´ÖÅù)
IF A(N)=0 THEN !' £°¤ÇÆþÎϽªÎ»
LET N=N-1
EXIT DO
END IF
LET SUM=SUM+A(N)
!' INPUT PROMPT "¥¿¥¤¥È¥ë(" & STR$(N) & ") ":T$(N) !'(¥Õ¥¡¥¤¥ë̾¡¢¶Ê̾Åù)
LET N=N+1
LOOP
INPUT PROMPT "ÌÜɸÃÍ=":MAXSIZE !'(¥á¥Ç¥£¥¢ÍÆÎÌ¡¢¶õ¤ÍÆÎÌÅù)
IF MAXSIZE >= SUM THEN
CALL DISPLAY(N,A,T$)
STOP
END IF
!' INPUT PROMPT "µöÍÆÈÏ°Ï=":EPS !'ÌÜɸÃÍ - ¹ç·×ÃÍ <= µöÍÆÈÏ°Ï ¤È¤Ê¤ëÁȤ߹ç¤ï¤»¤Îɽ¼¨
LET MMIN=MAXSIZE
LET K=0
DO
LET K=K+1
FOR I=1 TO N
IF A(I) >= MAXSIZE/K THEN EXIT DO
NEXT I
LOOP UNTIL K=N
FOR R=K TO N-1
LET MSIZE=MAXSIZE
MAT TEMP=ZER
LET RR=R
CALL COMB(A,N,RR,TEMP,1)
IF MSIZE < MMIN THEN
LET MMIN=MSIZE
MAT C=B
MAT TI$=TT$
END IF
NEXT R
IF MMIN > 0 THEN CALL DISPLAY(N,C,TI$)
END
EXTERNAL SUB COMB(X(),N,R,A(),K)
IF R=0 THEN
LET S=0
FOR I=1 TO N
IF A(I)=1 THEN
LET S=S+X(I)
END IF
IF S > MAXSIZE THEN EXIT SUB
NEXT I
IF MAXSIZE >= S AND MAXSIZE-S <= MSIZE THEN
LET MSIZE=MAXSIZE-S
MAT B=ZER
MAT TT$=NUL$
LET M=0
FOR J=1 TO N
IF A(J)=1 THEN
LET M=M+1
LET B(M)=X(J)
LET TT$(M)=T$(J)
END IF
NEXT J
IF MSIZE <= EPS THEN
CALL DISPLAY(N,B,TT$)
END IF
END IF
ELSE
FOR I=K TO N-R+1
LET A(I)=1
CALL COMB(X,N,R-1,A,I+1)
LET A(I)=0
NEXT I
END IF
END SUB
EXTERNAL SUB DISPLAY(N,A(),K$())
LET S=0
FOR I=1 TO N
IF A(I)<>0 THEN
PRINT "No.";I;":";A(I);" ";K$(I)
LET S=S+A(I)
END IF
NEXT I
PRINT "·×";S;"»Äº¹";MAXSIZE-S
END SUB
OPTION BASE 0
PUBLIC NUMERIC MAXLEVEL
LET MAXLEVEL=20
DIM X(MAXLEVEL),Y(MAXLEVEL)
CALL COSINE(X)
CALL SINE(Y)
PRINT "COS(SIN(X))"
CALL HORNER(X,Y)
CALL DISPLAY(X)
LET XX=.5
PRINT VALUE(X,XX);COS(SIN(XX)) !'¸¡»»
PRINT
CALL CLR(X)
LET X(0)=-1
LET X(2)=2 !'2*X^2-1 COS 2ÇܳѼ°
CALL REPEATFUNC(X,4) !'COS 2^4ÇܳѼ°
PRINT "F(F(F(F(X))))"
CALL DISPLAY(X)
LET XX=COS(RAD(30)/2^4)
PRINT VALUE(X,XX);F(F(F(F(XX)))) !'¸¡»»
PRINT COS(RAD(30))
PRINT
CALL COSINE(X)
CALL RCPFUNC(X) !'µÕ¿ô
PRINT "1/COS(X)"
CALL DISPLAY(X)
LET XX=.5
PRINT VALUE(X,XX);1/COS(XX) !'¸¡»»
PRINT
CALL COSINE(X)
CALL SQRFUNC(X) !'Ê¿Êýº¬
PRINT "SQR(COS(X))"
CALL DISPLAY(X)
LET XX=.5
PRINT VALUE(X,XX);SQR(COS(XX)) !'¸¡»»
PRINT
CALL COSINE(X)
LET N=SQR(2)
CALL ROOTFUNC(X,N) !'ÈóÀ°¿ô¾è
PRINT "COS(X)^";N
CALL DISPLAY(X)
LET XX=.5
PRINT VALUE(X,XX);COS(XX)^N !'¸¡»»
PRINT
CALL COSINE(X)
CALL SINE(Y)
CALL POWERFUNC(X,Y) !'¿¹à¼°¾è
PRINT "COS(X)^SIN(X)"
CALL DISPLAY(X)
LET XX=.5
PRINT VALUE(X,XX);COS(XX)^SIN(XX) !'¸¡»»
END
EXTERNAL FUNCTION F(X)
LET F=2*X*X-1 !'COS 2ÇܳÑ
END FUNCTION
EXTERNAL FUNCTION VALUE(A(),XX) !'¿¹à¼° F(X)¤ÎÃÍ
LET N=DIMCHECK(A)
LET Y=A(N)
FOR I=N-1 TO 0 STEP -1
LET Y=Y*XX+A(I)
NEXT I
LET VALUE=Y
END FUNCTION
EXTERNAL SUB HORNER(F(),G())
!' ¿¹à¼° F[X}¤Ë¿¹à¼° G[X]¤òÂåÆþ F[G[X]]
OPTION BASE 0
DIM Y(MAXLEVEL)
LET N=DIMCHECK(F)
LET Y(0)=F(N)
FOR I=N-1 TO 0 STEP -1
CALL MUL(Y,G)
LET Y(0)=Y(0)+F(I)
NEXT I
CALL COPY(F,Y)
END SUB
EXTERNAL SUB REPEATFUNC(X(),N)
!'F[F[F[...F[X]]]]...]
OPTION BASE 0
DIM C(MAXLEVEL),T(MAXLEVEL)
CALL COPY(C,X)
CALL COPY(T,X)
FOR I=2 TO N
CALL HORNER(C,X)
CALL COPY(X,C)
CALL COPY(C,T)
NEXT I
END SUB
EXTERNAL SUB RCPFUNC(X())
!'1/(1-F[X])=1+F[X]+F[X]^2+F[X]^3+...¼ý«Ⱦ·Â(ABS(F[X]) < 1)
!'1/F[X]=1/(1-(1-F[X])
OPTION BASE 0
DIM C(MAXLEVEL),Y(MAXLEVEL)
LET Y(0)=1
FOR I=0 TO MAXLEVEL
LET C(I)=1 !'1+F[X]+F[X]^2+F[X]^3+...
NEXT I
CALL SUBST(Y,X) !'1-F[X]
CALL HORNER(C,Y)
CALL COPY(X,C)
END SUB
EXTERNAL SUB SQRFUNC(X())
!' SQR(1-(1-F[X])) ¼ý«Ⱦ·Â(ABS(F[X]) < 1)
OPTION BASE 0
DIM C(MAXLEVEL),Y(MAXLEVEL)
LET Y(0)=1
CALL SUBST(Y,X) !'1-F[X]
CALL COMB(C,1,-1,1,.5) !'(1-X)^.5
CALL HORNER(C,Y)
CALL COPY(X,C)
END SUB
EXTERNAL SUB ROOTFUNC(X(),N)
!' (1-(1-F[X]))^N ¼ý«Ⱦ·Â(ABS(F[X]) < 1)
OPTION BASE 0
DIM C(MAXLEVEL),Y(MAXLEVEL)
LET Y(0)=1
CALL SUBST(Y,X) !'1-F[X]
CALL COMB(C,1,-1,1,N) !'(1-X)^N
CALL HORNER(C,Y)
CALL COPY(X,C)
END SUB
EXTERNAL SUB LOGFUNC(X())
!'LOG(F[X])
OPTION BASE 0
DIM C(MAXLEVEL)
CALL LN(C)
LET X(0)=X(0)-1
CALL HORNER(C,X)
CALL COPY(X,C)
END SUB
EXTERNAL SUB EXPFUNC(X())
!'EXP(F[X])
OPTION BASE 0
DIM C(MAXLEVEL)
CALL EXPON(C)
CALL HORNER(C,X)
CALL COPY(X,C)
END SUB
EXTERNAL SUB POWERFUNC(F(),G())
!' F[X] ^ G[X] = EXP(G[X]*LOG(F[X]))
CALL LOGFUNC(F)
CALL MUL(F,G)
CALL EXPFUNC(F)
END SUB
EXTERNAL SUB DISPLAY(A())
LET N=DIMCHECK(A)
IF N > 1 THEN
IF A(N)<0 THEN PRINT "-";
IF ABS(A(N))<>1 THEN
PRINT STR$(ABS(A(N)));"*X^";STR$(N);
ELSE
PRINT "X^";STR$(N);
END IF
END IF
FOR I=N-1 TO 2 STEP -1
IF A(I)<>0 THEN
IF A(I) < 0 THEN PRINT "-"; ELSE PRINT "+";
IF ABS(A(I))<>1 THEN
PRINT STR$(ABS(A(I)));"*X^";STR$(I);
ELSEIF ABS(A(I))=1 THEN
PRINT "X^";STR$(I);
END IF
END IF
NEXT I
IF A(1)<>0 THEN
IF N > 1 THEN
IF A(1) < 0 THEN PRINT "-"; ELSE PRINT "+";
END IF
IF ABS(A(1))<>1 THEN
PRINT STR$(ABS(A(1)));"*X";
ELSEIF ABS(A(1))=1 THEN
PRINT "X";
END IF
END IF
IF A(0)<>0 THEN
IF A(0) < 0 THEN PRINT "-"; ELSE PRINT "+";
PRINT STR$(ABS(A(0)));
END IF
PRINT
END SUB
EXTERNAL SUB COMB(X(),A,B,M,N) !'Æó¹àÄêÍý ¼ý«Ⱦ·Â(ABS(F[X]) < 1)
!' (A+B*X^M)^N = A^N+N*A^(N-1)*B*X^M+N*(N-1)/2!*A^(N-2)*B^2*X^(2*M)+...B^N*X^(M*N)+B^N
CALL CLR(X)
LET NN=1
LET X(0)=A^N
FOR I=1 TO INT(MAXLEVEL/M)
LET NN=NN*(N-I+1)/I
LET X(M*I)=NN*A^(N-I)*B^I
NEXT I
END SUB
EXTERNAL SUB SINE(X())
!' SIN(X)
CALL CLR(X)
LET X(1)=1
LET T=1
FOR I=3 TO MAXLEVEL STEP 2
LET T=-T/(I-1)/I
LET X(I)=T
NEXT I
END SUB
EXTERNAL SUB COSINE(X())
!' COS(X)
CALL CLR(X)
LET X(0)=1
LET T=1
FOR I=2 TO MAXLEVEL STEP 2
LET T=-T/(I-1)/I
LET X(I)=T
NEXT I
END SUB
EXTERNAL SUB EXPON(X())
!' EXP(X)
LET X(0)=1
LET T=1
FOR I=1 TO MAXLEVEL
LET T=T/I
LET X(I)=T
NEXT I
END SUB
EXTERNAL SUB LN(X())
!'LOG(1+X)
LET X(0)=0
FOR I=1 TO MAXLEVEL
IF MOD(I,2)=1 THEN LET X(I)=1/I ELSE LET X(I)=-1/I
NEXT I
END SUB
EXTERNAL SUB SUBST(Y(),X())
FOR I=0 TO MAXLEVEL
LET Y(I)=Y(I)-X(I)
NEXT I
END SUB
EXTERNAL SUB COPY(X(),Y())
FOR I=0 TO MAXLEVEL
LET X(I)=Y(I)
NEXT I
END SUB
EXTERNAL SUB MUL(Y(),X())
OPTION BASE 0
DIM C(MAXLEVEL)
FOR J=0 TO MAXLEVEL
FOR I=0 TO MAXLEVEL-J
LET C(I+J)=C(I+J)+Y(I)*X(J)
NEXT I
NEXT J
CALL COPY(Y,C)
END SUB
EXTERNAL SUB CLR(X())
FOR I=0 TO MAXLEVEL
LET X(I)=0
NEXT I
END SUB
EXTERNAL FUNCTION DIMCHECK(X())
FOR N=MAXLEVEL TO 0 STEP -1
IF X(N)<>0 THEN EXIT FOR
NEXT N
LET DIMCHECK=N
END FUNCTION
!´Ø¿ô¡¢¥µ¥Ö¥ë¡¼¥Á¥ó¤ÎÄêµÁ
PUBLIC FUNCTION ASC$
EXTERNAL FUNCTION ASC$(x$) !Á´³Ñʸ»ú¤òȾ³Ñʸ»ú¤ËÊÑ´¹¤¹¤ë
LET xx$=""
FOR i=1 TO LEN(x$) !ÂоݤÎʸ»úÎó¤Ë¤Ä¤¤¤Æ
LET t=ORD(x$(i:i))
SELECT CASE t
CASE 9008 TO 9017 !¿ô»ú£°¡Á£¹
LET w$=CHR$(t-ORD("£°")+ORD("0"))
CASE 9025 TO 9050 !±Ñ»ú£Á¡Á£Ú
LET w$=CHR$(t-ORD("£Ú")+ORD("Z"))
CASE 9057 TO 9082 !±Ñ»ú£á¡Á£ú
LET w$=CHR$(t-ORD("£ú")+ORD("z"))
CASE 9505 TO 9590 !¥«¥¿¥«¥Ê
LET w$=KataTBL$(t) !ÊÑ´¹É½¤ò»²¾È¤·¤ÆÃÖ¤´¹¤¨¤ë
CASE 8481 !µ¹æ
LET w$=" "
CASE 8490
LET w$="!"
CASE 8521
LET w$=""""
CASE 8564
LET w$="#"
CASE 8560
LET w$="$"
CASE 8563
LET w$="%"
CASE 8565
LET w$="&"
CASE 8519
LET w$="'"
CASE 8522
LET w$="("
CASE 8523
LET w$=")"
CASE 8566
LET w$="*"
CASE 8540
LET w$="+"
CASE 8484
LET w$=","
CASE 8541
LET w$="-"
CASE 8485
LET w$="."
CASE 8511
LET w$="/"
CASE 8487
LET w$=":"
CASE 8488
LET w$=";"
CASE 8547
LET w$="<"
CASE 8545
LET w$="="
CASE 8548
LET w$=">"
CASE 8489
LET w$="?"
CASE 8567
LET w$="@"
CASE 8526
LET w$="["
CASE 8559
LET w$="\"
CASE 8527
LET w$="]"
CASE 8496
LET w$="^"
CASE 8498
LET w$="_"
CASE 8518
LET w$="`"
CASE 8528
LET w$="{"
CASE 8515
LET w$="|"
CASE 8529
LET w$="}"
CASE 8513
LET w$="~"
CASE 8483 !µ¹æ¡¡¢¨¥«¥¿¥«¥Ê
LET w$="Ž¡"
CASE 8534
LET w$="Ž¢"
CASE 8535
LET w$="Ž£"
CASE 8482
LET w$="Ž¤"
CASE 8486
LET w$="Ž¥"
CASE 8508
LET w$="Ž°"
CASE 8491
LET w$="ŽÞ"
CASE 8492
LET w$="Žß"
CASE ELSE
LET w$=CHR$(t) !¤½¤Î¤Þ¤Þ
END SELECT
LET xx$=xx$ & w$
NEXT i
LET ASC$=xx$
END FUNCTION
PUBLIC FUNCTION JIS$
EXTERNAL FUNCTION JIS$(x$) !Ⱦ³Ñʸ»ú¤òÁ´³Ñʸ»ú¤ËÊÑ´¹¤¹¤ë
LET xx$=""
LET i=1
DO WHILE i<=LEN(x$) !ÂоÝʸ»ú¤ò½ç¤ËÄ´¤Ù¤ë
LET t=ORD(x$(i:i))
SELECT CASE t
CASE 32 TO 126 !µ¹æ¡¦±Ñ¿ô»ú¤Ê¤é
LET xx$=xx$ & JisTBL$(t) !ÊÑ´¹É½¤ò»²¾È¤·¤ÆÃÖ¤´¹¤¨¤ë
CASE 161 TO 223 !Ⱦ³Ñ¥«¥¿¥«¥Ê¤Ê¤é
IF i<LEN(x$) THEN LET tt=ORD(x$(i+1:i+1)) ELSE LET tt=0
IF tt=222 AND ( (t>=182 AND t<=196) OR (t>=202 AND t<=206) ) THEN !¥«¡Á¥È¡¢¥Ï¡Á¥Û¤ÎÂùÅÀ
LET xx$=xx$ & CHR$(ORD(JisTBL$(t))+1) !£±Ê¸»ú¤È¤¹¤ë
LET i=i+1
ELSEIF tt=223 AND (t>=202 AND t<=206) THEN !¥Ï¡Á¥Û¤ÎȾÂùÅÀ
LET xx$=xx$ & CHR$(ORD(JisTBL$(t))+2)
LET i=i+1
ELSE
LET xx$=xx$ & JisTBL$(t)
END IF
CASE ELSE !¤½¤ì°Ê³°¤Ê¤é
LET xx$=xx$ & CHR$(t) !¤½¤Î¤Þ¤Þ
END SELECT
LET i=i+1 !¼¡¤Ø
LOOP
LET JIS$=xx$
END FUNCTION
PUBLIC FUNCTION ToHiragana$
EXTERNAL FUNCTION ToHiragana$(x$) !Á´³Ñ¥«¥¿¥«¥Ê¤ò¤Ò¤é¤¬¤Ê¤ËÊÑ´¹¤¹¤ë
LET xx$=x$
FOR i=1 TO LEN(x$) !ÂоÝʸ»ú¤ò½ç¤ËÄ´¤Ù¤ë
LET t=ORD(x$(i:i))
IF t<ORD("¥¡") OR t>ORD("¥ó") THEN
ELSE
LET xx$(i:i)=CHR$(t-ORD("¥¡")+ORD("¤¡"))
END IF
NEXT i
LET ToHiragana$=xx$
END FUNCTION
PUBLIC FUNCTION ToKatakana$
EXTERNAL FUNCTION ToKatakana$(x$) !¤Ò¤é¤¬¤Ê¤òÁ´³Ñ¥«¥¿¥«¥Ê¤ËÊÑ´¹¤¹¤ë
LET xx$=x$
FOR i=1 TO LEN(x$) !ÂоÝʸ»ú¤ò½ç¤ËÄ´¤Ù¤ë
LET t=ORD(x$(i:i))
IF t<ORD("¤¡") OR t>ORD("¤ó") THEN
ELSE
LET xx$(i:i)=CHR$(t-ORD("¤¡")+ORD("¥¡"))
END IF
NEXT i
LET ToKatakana$=xx$
END FUNCTION
END MODULE
DIM x(0 TO 20),y(0 TO 20),r(0 TO 20),g(0 TO 20),b(0 TO 20) !ĺÅÀ¤Î°ÌÃ֤ȿ§
SET WINDOW -10,10,-10,10 !ɽ¼¨Îΰè
DATA 1,0,0 !¿§RGB
DATA 1,1,0
DATA 0,1,0
DATA 0,1,1
DATA 0,0,1
DATA 1,0,1
DATA 1,0,0
CALL PLOT.Init !¢¨
LET x(0)=0 !»ÏÅÀ(0,0)¡¢½ªÅÀ(3,0)
LET x(1)=3
LET y(0)=0
LET y(1)=0
PICTURE L1 !²£Àþ
CALL PLOT.LINES(x,y,r,g,b) !¢¨
END PICTURE
READ r(0),g(0),b(0) !»ÏÅÀ¤Î¿§
FOR i=1 TO 6
READ r(1),g(1),b(1) !½ªÅÀ¤Î¿§
DRAW BAR WITH SHIFT(i*3-12,0)
LET r(0)=r(1) !¼¡¤Ø
LET g(0)=g(1)
LET b(0)=b(1)
NEXT i
PICTURE BAR !ËÀ¾õ
FOR j=8 TO -8 STEP -0.05
DRAW L1 WITH SHIFT(0,j)
NEXT j
END PICTURE
END
¡ü¥µ¥ó¥×¥ë£²
DIM x(0 TO 20),y(0 TO 20),r(0 TO 20),g(0 TO 20),b(0 TO 20) !ĺÅÀ¤Î°ÌÃ֤ȿ§
SET WINDOW -10,10,-10,10 !ɽ¼¨Îΰè
DATA 1,0,0 !¿§RGB
DATA 1,1,0
DATA 0,1,0
DATA 0,1,1
DATA 0,0,1
DATA 1,0,1
DATA 1,0,0
CALL PLOT.Init !¢¨
LET x(0)=0 !£±ÅÀÌܤΰÌÃÖ¡ÊÃæ±û¡Ë
LET y(0)=0
LET r(0)=0.2 !ĺÅÀ¤Î¿§
LET g(0)=0.2
LET b(0)=0.2
LET x(1)=9*COS(0) !£²ÅÀÌÜ
LET y(1)=9*SIN(0)
READ r(1),g(1),b(1)
FOR i=1 TO 6 !Ï»³Ñ·Á¡¡¢¨»°³Ñ·Á¤¬£¶¤Ä
LET x(2)=9*COS(i*PI/3) !£³ÅÀÌÜ
LET y(2)=9*SIN(i*PI/3)
READ r(2),g(2),b(2)
CALL PLOT.AREALIMIT(3, x,y, r,g,b) !¢¨
LET x(1)=x(2) !¼¡¤Ø
LET y(1)=y(2)
LET r(1)=r(2)
LET g(1)=g(2)
LET b(1)=b(2)
NEXT i
END
MODULE PLOT !³ÆĺÅÀ¤Î¿§¤ò¤â¤È¤ËÀþʬ¤ÈÆÌ¿³Ñ·Á¤Ë¥°¥é¥Ç¡¼¥·¥ç¥ó¤ò¤«¤±¤ë
SET POINT STYLE 1 !¥Þ¡¼¥¯¤Î·Á¾õ
SHARE NUMERIC Xmin(0 TO 1024),Xmax(0 TO 1024) !yºÂɸ(y¹Ô)¤Ë¤ª¤±¤ëxºÂɸ¤ÎºÇ¾®ÃÍ¡¢ºÇÂçÃÍ¡¡¢¨Í×Ä´À°
SHARE NUMERIC Rmin(0 TO 1024),Rmax(0 TO 1024)
SHARE NUMERIC Gmin(0 TO 1024),Gmax(0 TO 1024)
SHARE NUMERIC Bmin(0 TO 1024),Bmax(0 TO 1024)
SHARE NUMERIC ww,hh !¥¹¥¯¥ê¡¼¥ó¤Î°ÌÃÖ¡¢Â礤µ
EXTERNAL SUB Init !¥ì¥ó¥À¥ê¥ó¥°¥¿¡¼¥²¥Ã¥È¤ò½é´ü²½¤¹¤ë
SET COLOR mode "NATIVE" !RGB»ØÄê
SET TEXT font "",12 !ʸ»ú¥µ¥¤¥º
ASK WINDOW x1,x2,y1,y2 !ºÂɸ·Ï¤Îü¤ÎºÂɸ¤ò¼èÆÀ¤¹¤ë
ASK PIXEL SIZE (x1,y1; x2,y2) ww,hh !²èÌ̤ÎÂ礤µ(¥Ô¥¯¥»¥ëñ°Ì)¤òÄ´¤Ù¤ë
END SUB
EXTERNAL SUB SetPixel(x,y,c) !ºÂɸ(x,y,z)¤Ë¿§(r,g,b)¤ÇÅÀ¤òÉÁ¤¯¡¡¢¨PLOT POINTS: x,y ¤ÈƱ¤¸
SET POINT COLOR c
PLOT POINTS: WORLDX(x), WORLDX(y) !ÌäÂêºÂɸ¤ËÌᤷ¤ÆÉÁ¤¯
!!!PLOT POINTS: x * (x2 - x1) / ww + x1, y * (y2 - y1) / hh + y1 !ÌäÂêºÂɸ¤ËÌᤷ¤ÆÉÁ¤¯
END SUB
PUBLIC SUB POINTS !¢¨PLOT POINTS: x,y ¤ÈƱ¤¸
EXTERNAL SUB POINTS(xx,yy,rr,gg,bb) !Àþʬ¤òÉÁ²è¤¹¤ë
LET x1 = PIXELX(xx)
LET y1 = PIXELY(yy)
IF (y1 >= 0) AND (y1 < hh) THEN !²èÌÌÆâ¤Ê¤é
IF (x1 >= 0) AND (x1 < ww) THEN
CALL SetPixel(INT(x1),INT(y1), colorindex(rr,gg,bb))
END IF
END IF
END SUB
PUBLIC SUB LINES !¢¨PLOT LINES: x0,y0; x1,y1 ¤Þ¤¿¤Ï MAT PLOT LINES,LIMIT 2: x,y ¤ÈƱ¤¸
EXTERNAL SUB LINES(xx(),yy(),rr(),gg(),bb()) !Àþʬ¤òÉÁ²è¤¹¤ë
LET x1 = PIXELX(xx(0))
LET y1 = PIXELY(yy(0))
LET x2 = PIXELX(xx(1))
LET y2 = PIXELY(yy(1))
LET r1 = rr(0) !½é´üÃͤòÀßÄꤹ¤ë
LET g1 = gg(0)
LET b1 = bb(0)
SET DRAW mode hidden !¤Á¤é¤Ä¤ËÉ»ß(³«»Ï)
IF (x1 = x2) AND (y1 = y2) THEN !»ÏÅÀ¤È½ªÅÀ¤¬Æ±¤¸¤Ê¤é
IF (y1 >= 0) AND (y1 < hh) THEN !²èÌÌÆâ¤Ê¤é
IF (x1 >= 0) AND (x1 < ww) THEN
CALL SetPixel(INT(x1),INT(y1), colorindex(r1,g1,b1))
END IF
END IF
ELSE
LET dx = x2 - x1 !ÁêÂÐŪŤµ
LET dy = y2 - y1
IF ABS(dy) < ABS(dx) THEN !x¤ÎÊý¤¬Áýʬ¤¬Â¿¤¤
!¢¢¢¢¢¢¢£
!¢¢¢£¢£¢¢¡¡¡¡y=l*x+m¤Î¼°¤È¤·¤Æ¹Í¤¨¤ë
!¢£¢¢¢¢¢¢
LET l = dy / dx !·¹¤¤òµá¤á¤ë
LET dr = (rr(1) - rr(0)) / dx
LET dg = (gg(1) - gg(0)) / dx
LET db = (bb(1) - bb(0)) / dx
FOR i=0 TO dx STEP SGN(dx)
LET x = x1 + i
LET y = l * i + y1
LET r = dr * i + r1
LET g = dg * i + g1
LET b = db * i + b1
IF (y >= 0) AND (y < hh) THEN !²èÌÌÆâ¤Ê¤é
IF (x >= 0) AND (x < ww) THEN
CALL SetPixel(INT(x),INT(y), colorindex(r,g,b))
END IF
END IF
NEXT i
ELSE !y¤ÎÊý¤¬Áýʬ¤¬Â¿¤¤
!¢¢¢¢¢£
!¢¢¢£¢¢¡¡¡¡x=l*y+m¤Î¼°¤È¤·¤Æ¹Í¤¨¤ë
!¢¢¢£¢¢
!¢£¢¢¢¢
LET l = dx / dy !·¹¤¤òµá¤á¤ë
LET dr = (rr(1) - rr(0)) / dy
LET dg = (gg(1) - gg(0)) / dy
LET db = (bb(1) - bb(0)) / dy
FOR i=0 TO dy STEP SGN(dy)
LET x = l * i + x1
LET y = y1 + i
LET r = dr * i + r1
LET g = dg * i + g1
LET b = db * i + b1
IF (y >= 0) AND (y < hh) THEN !²èÌÌÆâ¤Ê¤é
IF (x >= 0) AND (x < ww) THEN
CALL SetPixel(INT(x),INT(y), colorindex(r,g,b))
END IF
END IF
NEXT i
END IF
END IF
SET DRAW mode explicit !¤Á¤é¤Ä¤ËÉ»ß(½ªÎ»)
END SUB
PUBLIC SUB AREALIMIT !!¢¨MAT PLOT AREA,LIMIT n: x,y ¤ÈƱ¤¸
EXTERNAL SUB AREALIMIT(NumOfVtx, xx(),yy(),rr(),gg(),bb()) !ÆÌ¿³Ñ·Á(ĺÅÀÈÖ¹æ¤Ë¤è¤ëÌ̤ÎÄêµÁ)¤òÉÁ²è¤¹¤ë
IF NumOfVtx < 3 THEN EXIT SUB
DIM sx(0 TO NumOfVtx-1),sy(0 TO NumOfVtx-1)
FOR i=0 TO NumOfVtx-1 !ÌäÂêºÂɸ¤«¤é¥Ô¥¯¥»¥ëºÂɸ¤ËÊÑ´¹¤¹¤ë
LET sx(i) = PIXELX(xx(i))
LET sy(i) = PIXELY(yy(i))
!!!LET sx(i) = (xx(i) - x1) * ww / (x2 - x1)
!!!LET sy(i) = (yy(i) - y1) * hh / (y2 - y1)
NEXT i
LET top = +2147483647 !¥Ð¥Ã¥Õ¥¡¤Î»ÈÍÑÈϰϤòÀßÄꤹ¤ë
LET btm = -2147483648
FOR i=0 TO NumOfVtx-1
IF top > sy(i) THEN LET top = sy(i)
IF btm < sy(i) THEN LET btm = sy(i)
NEXT i
LET top = INT(top)
LET btm = INT(btm)
IF top < 0 THEN LET top = 0
IF btm > hh THEN LET btm = hh
FOR i=top TO btm-1 !ºÇÂçºÇ¾®¥Ð¥Ã¥Õ¥¡¤ò½é´ü²½¤¹¤ë
LET Xmin(i) = +2147483647
LET Xmax(i) = -2147483648
NEXT i
FOR i=0 TO NumOfVtx-2 !ÎÇÀþ¤Î¿ô¤À¤±
CALL ScanEdge(i,i+1, sx,sy,rr,gg,bb) !ÎÇÀþ¤¬ÉÁ¤¯³ÆÅÀ¤òµá¤á¤ë
NEXT i
CALL ScanEdge(NumOfVtx-1,0, sx,sy,rr,gg,bb)
SET DRAW mode hidden !¤Á¤é¤Ä¤ËÉ»ß(³«»Ï)
FOR y=top TO btm-1 !³Æ¥é¥¤¥ó(yºÂɸ)¤´¤È¤ËÁöºº¤¹¤ë - ¥é¥¹¥¿¥é¥¤¥º
LET l = (Xmax(y) - Xmin(y)) + 1 !ÁýʬÃͤò·×»»¤¹¤ë
LET dr = (Rmax(y) - Rmin(y)) / l
LET dg = (Gmax(y) - Gmin(y)) / l
LET db = (Bmax(y) - Bmin(y)) / l
LET r = Rmin(y) !½é´üÃͤòÀßÄꤹ¤ë
LET g = Gmin(y)
LET b = Bmin(y)
FOR x=Xmin(y) TO Xmax(y) !¥é¥¤¥ó¾å¤Ç¤ÎľÀþ¤òÉÁ¤¯¡¡¢¨PLOT LINES: Xmin(y),y; Xmax(y),y
IF (x >= 0) AND (x < ww) THEN !²èÌÌÆâ¤Ê¤é
CALL SetPixel(x,y,colorindex(r,g,b)) !ÌäÂêºÂɸ¤ËÌᤷ¤ÆÉÁ¤¯
END IF
LET r = r + dr !¼¡¤Ø
LET g = g + dg
LET b = b + db
NEXT x
NEXT y
SET DRAW mode explicit !¤Á¤é¤Ä¤ËÉ»ß(½ªÎ»)
END SUB
EXTERNAL SUB ScanEdge(v1,v2, xx(),yy(),rr(),gg(),bb()) !ĺÅÀv1¤ÈĺÅÀv2¤ò·ë¤ÖÎÇÀþ(ÊÕ)¤¬ÉÁ¤¯³ÆÅÀ¤òµá¤á¤ë
LET l = ABS(INT(yy(v2) - yy(v1))) + 1 !Éý¤ò·×»»¤¹¤ë
LET dx = (xx(v2) - xx(v1)) / l !ÁýʬÃͤò·×»»¤¹¤ë
LET dy = (yy(v2) - yy(v1)) / l
LET dr = (rr(v2) - rr(v1)) / l
LET dg = (gg(v2) - gg(v1)) / l
LET db = (bb(v2) - bb(v1)) / l
LET x = xx(v1) !½é´üÃͤòÀßÄꤹ¤ë
LET y = yy(v1)
LET r = rr(v1)
LET g = gg(v1)
LET b = bb(v1)
FOR i=0 TO l-1 !³Æ¥é¥¤¥ó(yºÂɸ)¤´¤È¤Ë
LET px = INT(x)
LET py = INT(y)
IF (py >= 0) AND (py < hh) THEN !²èÌÌÆâ¤Ê¤é
IF Xmin(py) > px THEN !º¸Ã¼°ÌÃÖ¤òµÏ¿¤¹¤ë
LET Xmin(py) = px
LET Rmin(py) = r
LET Gmin(py) = g
LET Bmin(py) = b
END IF
IF Xmax(py) < px THEN !±¦Ã¼°ÌÃÖ¤òµÏ¿¤¹¤ë
LET Xmax(py) = px
LET Rmax(py) = r
LET Gmax(py) = g
LET Bmax(py) = b
END IF
END IF
LET x = x + dx !¼¡¤Ø
LET y = y + dy
LET r = r + dr
LET g = g + dg
LET b = b + db
NEXT i
END SUB
END MODULE
!£å¤Î9000·å
!main(){int N=9009,n=N,a[9009],x;while(--n)a[n]=1+1/n;
!for(;N>9;printf("%d",x))
!for(n=N--;--n;a[n]=x%n,x=10*a[n-1]+x/n);}
!À°·Á¤¹¤ë¤È
!main(){
! int N=9009,n=N,a[9009],x;
! while(--n)
! a[n]=1+1/n;
! for( ;N>9; printf("%d",x) )
! for( n=N--; --n; a[n]=x%n, x=10*a[n-1]+x/n );
!}
REM---> main(){
!nop
REM---> int N=9009,n=N,a[9009],x;
LET N=9009
LET n_=N !¢¨£Ã¸À¸ì¤ÏÂçʸ»ú¤È¾®Ê¸»ú¤Ï¶èÊ̤µ¤ì¤ë
DIM a(0 TO 9009-1) !¢¨£Ã¸À¸ì¤Ï½é´ü²½¤·¤Ê¤¤¤¿¤áÃͤÏÉÔÄê
LET x=0 !¢¨
REM --> while(--n)
DO
LET n_=n_-1
IF n_=0 THEN EXIT DO
REM --> a[n]=1+1/n;
LET a(n_)=1+IP(1/n_)
LOOP
REM---> for(;N>9;printf("%d",x))
!nop !for(¢¨; ; )Éôʬ
DO !for( ;¢¨; )Éôʬ
IF NOT N>9 THEN EXIT DO
REM---> for(n=N--;--n;a[n]=x%n,x=10*a[n-1]+x/n)
LET n_=N !for(¢¨; ; )Éôʬ
LET N=N-1
DO !for( ;¢¨; )Éôʬ
LET n_=n_-1
IF NOT n_<>0 THEN EXIT DO
REM---> ;
LET a(n_)=REMAINDER(x,n_) !for( ; ;¢¨)Éôʬ
LET x=10*a(n_-1)+IP(x/n_)
LOOP
PRINT x; !for( ; ;¢¨)Éôʬ
LOOP
REM---> }
END
¡ü¥µ¥ó¥×¥ë£²
!¦Ð
!main(){int a=1e4,c=3e3,b=c,d=0,e=0,f[3000],g=1,h=0;
!for(;b;!--b?printf("%04d",e+d/a),e=d%a,h=b=c-=15:f[b]=(d=d/g*b+a*(h?f[b]:2e3))%(g=b*2-1));}
!À°·Á¤¹¤ë¤È
!main(){
! int a=1e4,
! c=3e3,
! b=c,
! d=0,
! e=0,
! f[3000],
! g=1,
! h=0;
! for(;
! b;
! !--b?
! printf("%04d",e+d/a),
! e=d%a,
! h=b=c-=15
! :
! f[b]=(d=d/g*b+a*(h?
! f[b]
! :
! 2e3
! )
! )%(g=b*2-1)
! )
! ;
!}
REM---> main(){
!nop
REM---> int a=1e4,c=3e3,b=c,d=0,e=0,f[3000],g=1,h=0;
LET a=1E4
LET c=3E3
LET b=c
LET d=0
LET e=0
DIM f(0 TO 3000-1) !¢¨£Ã¸À¸ì¤Ï½é´ü²½¤·¤Ê¤¤¤¿¤áÃͤÏÉÔÄê
LET g=1
LET h=0
REM---> for(;b;!--b?printf("%04d",e+d/a),e=d%a,h=b=c-=15:f[b]=(d=d/g*b+a*(h?f[b]:2e3))%(g=b*2-1))
!nop !for(¢¨; ; )Éôʬ
DO !for( ;¢¨; )Éôʬ
IF NOT b<>0 THEN EXIT DO
REM---> ;
!for( ; ;¢¨)Éôʬ
LET b=b-1 ! !--b?¡Á:¡ÁÉôʬ
IF NOT b<>0 THEN
PRINT USING "%%%%": e+IP(d/a); !printf("%04d",e+d/a),
LET e=REMAINDER(d,a) !e=d%a,
LET AX_=c-15 !h=b=c-=15
LET h,b,c=AX_
ELSE
IF h<>0 THEN LET AX_=f(b) ELSE LET AX_=2E3 !h?¡Á:¡ÁÉôʬ
LET d=IP(d/g)*b+a*AX_ !d=d/g*b+a*(¡Á)Éôʬ
LET g=b*2-1 !g=b*2-1Éôʬ
LET f(b)=REMAINDER(d,g) !f[b]=(¡Á)%(¡Á)
END IF
LOOP
REM---> }
END
!£²¤ÎÊ¿Êýº¬¤Î2400·å
!main(){int a=1000,b=0,c=1413,d,f[1414],n=800,k;
!for(;b<c;f[b++]=14);
!for(;n--;d+=*f*a,printf("%.3d",d/a),*f=d%a)
!for(d=0,k=c;--k;d/=b,d*=2*k-1)f[k]=(d+=f[k]*a)%(b=100*k);}
!À°·Á¤¹¤ë¤È
!main(){
! int a=1000,b=0,c=1413,d,f[1414],n=800,k;
! for( ;b<c; f[b++]=14 );
! for( ;n--; d+=*f*a,printf("%.3d",d/a),*f=d%a )
! for( d=0,k=c; --k; d/=b,d*=2*k-1 )
! f[k]=(d+=f[k]*a)%(b=100*k);
! }
REM---> main(){
!nop
REM---> int a=1000,b=0,c=1413,d,f[1414],n=800,k;
LET a=1000
LET b=0
LET c=1413
DIM f(0 TO 1414-1) !¢¨£Ã¸À¸ì¤Ï½é´ü²½¤·¤Ê¤¤¤¿¤áÃͤÏÉÔÄê
LET n=800
LET k=0 !¢¨£Ã¸À¸ì¤Ï½é´ü²½¤·¤Ê¤¤¤¿¤áÃͤÏÉÔÄê
REM---> for( ;b<c; f[b++]=14 );
!nop !for(¢¨; ; )Éôʬ
DO !for( ;¢¨; )Éôʬ
IF NOT b<c THEN EXIT DO
REM--> ;
LET f(b)=14 !for( ; ;¢¨)Éôʬ
LET b=b+1
LOOP
REM---> for( ;n--; d+=*f*a,printf("%.3d",d/a),*f=d%a )
!nop !for(¢¨; ; )Éôʬ
DO !for( ;¢¨; )Éôʬ
IF NOT n<>0 THEN EXIT DO
LET n=n-1
REM---> for(d=0,k=c; --k; d/=b,d*=2*k-1 )
LET d=0 !for(¢¨; ; )Éôʬ
LET k=c
DO !for( ;¢¨; )Éôʬ
LET k=k-1
IF NOT k<>0 THEN EXIT DO
REM--> f[k]=(d+=f[k]*a)%(b=100*k);
LET d=d+f(k)*a
LET b=100*k
LET f(k)=REMAINDER(d,b)
LET d=IP(d/b) !for( ; ;¢¨)Éôʬ
LET d=d*(2*k-1)
LOOP
LET d=d+f(0)*a !for( ; ;¢¨)Éôʬ
PRINT USING "%%%": IP(d/a) !ºÇ¾®·å¿ô£³·å
LET f(0)=REMAINDER(d,a)
LOOP
REM---> }
END
·ë²Ì¤òʬ¿ô¤Î·Á¤Ç¤Û¤·¤¤¤È¤¤ÏÍÍý¿ô¥â¡¼¥É¤ò»È¤¤¤Þ¤¹¡£
10 OPTION ARITHMETIC RATIONAL
20 LET t=0
30 FOR k=1 TO 1129
40 LET t=t+1/k
50 NEXT k
60 PRINT t
70 END
¤¿¤À¤·¡¤ÍÍý¿ô¥â¡¼¥É¤ÏJISµ¬³Ê¤ÎÈϰϳ°¤Ç¤¹¡£
ɸ½àBASIC¤ÎÈÏ°ÏÆâ¤Ç¤³¤Î·×»»¤ò¹Ô¤¦¥×¥í¥°¥é¥à¤òºî¤ë¤Î¤Ï¾åµé¼Ô¸þ¤¤Î²ÝÂê¤Ç¤¹¡£
!Äê¿ô
DECLARE EXTERNAL NUMERIC MultiPrecision.RADIX, MultiPrecision.L2
DECLARE EXTERNAL NUMERIC MultiPrecision.c0(), MultiPrecision.c1()
!񂯯
DECLARE EXTERNAL FUNCTION MultiPrecision.lNum2Str$, MultiPrecision.lcomp
DECLARE EXTERNAL SUB MultiPrecision.lStr2Num, MultiPrecision.lcopy
DECLARE EXTERNAL SUB MultiPrecision.ladd, MultiPrecision.lsub
DECLARE EXTERNAL SUB MultiPrecision.lmul, MultiPrecision.ldiv
DECLARE EXTERNAL SUB MultiPrecision.llmul, MultiPrecision.ldivqr
!----------------------------------------
!¦²[k=1,n]1/k ¤Î·×»»
LET t0=TIME
DIM P(0 TO L2),Q(0 TO L2)
CALL lStr2Num("0",P) !t=P/Q=1
CALL lStr2Num("1",Q)
DIM T1(0 TO L2),T2(0 TO L2)
FOR k=1 TO 1129
CALL lmul(P,k, T1) !t=t+1/k=(P*k+Q)/(Q*k)¡¡ÄÌʬ
CALL ladd(T1,Q, P)
CALL lmul(Q,k, T2)
CALL lcopy(T2,Q)
NEXT k
PRINT lNum2Str$(P)
PRINT lNum2Str$(Q)
DIM A(0 TO L2),B(0 TO L2)
CALL lcopy(P,A) !LET A=P !copy it
CALL lcopy(Q,B) !LET B=Q
LET c=0 !·«¤êÊÖ¤·²ó¿ô debug
DO UNTIL lcomp(B,c0)=0 !ºÇÂç¸øÌó¿ô¤òµá¤á¤ë
LET c=c+1 !debug
CALL ldivqr(A,B, T1,T2) !LET R=MOD(A,B) !MOD(x,y)=x-y*INT(x/y)
CALL lcopy(B,A) !LET A=B
CALL lcopy(T2,B) !LET B=R
LOOP
PRINT "c=";c !debug
PRINT "gcd=";lNum2Str$(A) !PRINT "gcd=";A !debug
CALL ldivqr(P,A, T1,T2) !LET P=P/A !Ìóʬ
CALL lcopy(T1,P)
CALL ldivqr(Q,A, T1,T2) !LET Q=Q/A
CALL lcopy(T1,Q)
PRINT "P=";lNum2Str$(P) !PRINT "P=";P !·ë²Ì¤Îɽ¼¨
PRINT "Q=";lNum2Str$(Q) !PRINT "Q=";Q
PRINT TIME-t0
END
MODULE MultiPrecision !Àµ¤Î¿·å¡Ê¿ÇÜĹ¡ËÀ°¿ô¤Î·×»»
!·å¤Î¿ô»ú¤ÎÎó¤ò³ÊǼ¤¹¤ëÇÛÎóa()¤ò¹Í¤¨¤ë¡£
!¾å°Ì·å¡¡¡¡¡¡¡¡¡¡¡¡²¼°Ì·å
!a(L2),a(L2-1),¡Ä,a(1),a(0)¡¡¤Î¹½Â¤¤Çɽ¤¹¤³¤È¤¬¤Ç¤¤ë¡£
!¸À¤¤´¹¤¨¤ë¤È¡¢n¿Ê¿ôɽµ¤Î³Æ·å¤¬a()¤È¤Ê¤ë¡£
!¤¿¤È¤¨¤Ð¡¢100¿Ê¿ô¤È¤¹¤ë¤È¡¢a(k)¤ÏÀµ¤ÎÀ°¿ô£²·å¡Ê0¡Á99¡Ë¤È¤Ê¤ë¡£
!Îã. 12345¤Ï1*100*100+23*100+45¤À¤«¤é¡¢a(2)=1¡¢a(1)=23¡¢a(0)=45¡£
SHARE NUMERIC KETA
PUBLIC NUMERIC RADIX,L2
LET KETA=4 !·å¿ô 1,2,3,4¡¡¢¨32bit¤«64bitÀ°¿ô¤ÎÈÏ°Ï
LET RADIX=10^KETA !´ð¿ô
LET L=3000 !µá¤á¤ë·å¿ô¡¡¢¨
LET L2=INT(L/KETA)+1 !ÇÛÎó¤ÎÂ礤µ
PUBLIC NUMERIC c0(0 TO 1000) !¢¨
CALL lStr2Num("0",c0) !Äê¿ô£°
PUBLIC NUMERIC c1(0 TO 1000) !¢¨
CALL lStr2Num("1",c1) !Äê¿ô£±
SHARE NUMERIC aa(0 TO 1000),bb(0 TO 1000),m(0 TO 1000) !ºî¶ÈÍÑ¡¡¢¨
!----- ²¼°Ì¤Î±é»»¥ë¡¼¥Á¥ó
PUBLIC SUB ladd
EXTERNAL SUB ladd(a(),b(), c()) !¿·å¡Ü¿·å¡¡¢¨C=A+B
LET cy=0 !·å¾å¤¬¤ê
FOR i=0 TO L2 !²¼¤Î·å¤«¤é
LET d=a(i)+b(i)+cy !Ʊ¤¸·å¤Ç
IF d<RADIX THEN
LET c(i)=d
LET cy=0
ELSE
LET c(i)=d-RADIX
LET cy=1 !¾å¤Î·å¤Ø
END IF
NEXT i
IF cy>0 THEN
PRINT "²Ã»»¥ª¡¼¥Ð¡¼¥Õ¥í¡¼"
STOP
END IF
END SUB
PUBLIC SUB lsub
EXTERNAL SUB lsub(a(),b(), c()) !¿·å¡Ý¿·å¡¡¢¨A>B¡¢C=A-B
LET brrw=0 !¼Ú¤ê
FOR i=0 TO L2 !²¼¤Î·å¤«¤é
LET d=a(i)-b(i)-brrw !Ʊ¤¸·å¤Ç
IF d>=0 THEN
LET c(i)=d
LET brrw=0
ELSE
LET c(i)=d+RADIX
LET brrw=1 !¾å¤Î·å¤«¤é¼Ú¤ê¤ë
END IF
NEXT i
IF brrw>0 THEN
PRINT "¸º»»A-B¤Ç¡¢A>B¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£"
STOP
END IF
END SUB
PUBLIC SUB lmul
EXTERNAL SUB lmul(a(),b, c()) !¿·å¡ßÀµ¤ÎÀ°¿ô¡Ê0¡Á255¡Ë¢¨10000¿Ê¿ô¤Ê¤é32767
LET cy=0
FOR i=0 TO L2 !²¼¤Î·å¤«¤é
LET d=a(i)*b+cy
LET cy=INT(d/RADIX) !·å¾å¤¬¤ê
LET c(i)=MOD(d,RADIX) !¤³¤Î·å
NEXT i
IF cy>0 THEN
PRINT "¾è»»¥ª¡¼¥Ð¡¼¥Õ¥í¡¼"
STOP
END IF
END SUB
PUBLIC SUB ldiv
EXTERNAL SUB ldiv(a(),b, c()) !¿·å¡àÀµ¤ÎÀ°¿ô¡Ê0¡Á255¡Ë¢¨10000¿Ê¿ô¤Ê¤é32767
IF b=0 THEN
PRINT "£°¤Ç¤Ï³ä¤ì¤Þ¤»¤ó¡£"
STOP
END IF
LET r=0 !;¤ê
FOR i=L2 TO 0 STEP -1 !¾å¤Î·å¤«¤é
LET d=a(i)+r
LET c(i)=INT(d/b) !¾¦¤Ï¤³¤Î·å
LET r=MOD(d,b)*RADIX !;¤ê¤ò²¼¤Î·å¤Ø
NEXT i
END SUB
PUBLIC SUB lcopy
EXTERNAL SUB lcopy(a(), b()) !¥³¥Ô¡¼ B=A
FOR i=0 TO L2 !mat b=a
LET b(i)=a(i) !Ʊ¤¸·å¤Ç
NEXT i
END SUB
PUBLIC FUNCTION lcomp
EXTERNAL FUNCTION lcomp(a(),b()) !Èæ³Ó¡¡A>B¤Ê¤é1¡¢A=B¤Ê¤é0¡¢A<B¤Ê¤é-1
FOR i=L2 TO 0 STEP -1 !¾å¤Î·å¤«¤é
IF a(i)>b(i) THEN
LET lcomp=1
EXIT FUNCTION
ELSEIF a(i)<b(i) THEN
LET lcomp=-1
EXIT FUNCTION
END IF
NEXT i
LET lcomp=0
END FUNCTION
!----- ÆþÎÏ¡¢½ÐÎϥ롼¥Á¥ó
PUBLIC SUB lStr2Num
EXTERNAL SUB lStr2Num(a$, a()) !¿ô»úÎó¤ò¿·åÀ°¿ô¤ËÊÑ´¹¤¹¤ë
FOR i=0 TO L2
LET A(i)=0
NEXT i
FOR i=LEN(a$) TO 1 STEP -KETA
LET d=INT((LEN(a$)-i)/KETA)
IF d>L2 THEN
PRINT "·å¿ô¤¬Â¤ê¤Þ¤»¤ó¡£"
STOP
END IF
LET a(d)=VAL(a$(i-KETA+1:i))
NEXT i
END SUB
PUBLIC FUNCTION lNum2Str$
EXTERNAL FUNCTION lNum2Str$(a()) !¿·åÀ°¿ô¤ò¿ô»úÎó¤ËÊÑ´¹¤¹¤ë
LET aMSD=GetMSD(a)
IF aMSD<0 THEN !£°¤Ê¤é
LET a$=" 0"
ELSE
LET a$=" "&STR$(a(aMSD)) !£±·åÌÜ
FOR i=aMSD-1 TO 0 STEP -1 !£²·åÌܰʹß
LET a$=a$&right$("000"&STR$(a(i)),4)
NEXT i
END IF
LET lNum2Str$=a$
END FUNCTION
!----- ¾å°Ì¤Î±é»»¥ë¡¼¥Á¥ó
PUBLIC SUB llmul
EXTERNAL SUB llmul(a(),b(), c()) !¿·å¡ß¿·å¡¡¢¨C=A*B
FOR i=0 TO L2*2 !mat c=zer
LET c(i)=0
NEXT i
LET aMSD=GetMSD(a)
LET bMSD=GetMSD(b)
IF aMSD<0 OR bMSD<0 THEN EXIT SUB !¾è¿ô¡¢Èï¾è¿ô¤¬£°¤Ê¤é
FOR j=0 TO bMSD !¾è¿ô¡§²¼¤Î·å¤«¤é
LET cy=0
IF b(j)>0 THEN !£°¤Ï·×»»¤·¤Ê¤¤
FOR i=0 TO aMSD !Èï¾è¿ô¡§²¼¤Î·å¤«¤é
LET d=a(i)*b(j)+cy + c(i+j) !ÎßÀÑ¡¡¢¨É®»»»²¾È O(n^2)
LET c(i+j)=MOD(d,RADIX) !¤³¤Î·å
LET cy=INT(d/RADIX) !·å¾å¤¬¤ê
NEXT i
IF cy>0 THEN LET c(j+aMSD+1)=cy !¾å°Ì·å¤Ø
END IF
NEXT j
END SUB
EXTERNAL FUNCTION GetMSD(a()) !ºÇ¾å°Ì·å¤Î°ÌÃÖ¤òÆÀ¤ë
FOR i=L2 TO 0 STEP -1
IF a(i)<>0 THEN EXIT FOR
NEXT i
LET GetMSD=i !·å°ÌÃÖ¡¡¢¨£°¤Ê¤é-1
END FUNCTION
PUBLIC SUB ldivqr
EXTERNAL SUB ldivqr(a(),b(), q(),r()) !¿·å¡à¿·å¡¡¢¨¾¦q ;¤êr
LET bMSD=GetMSD(b)
IF bMSD<0 THEN !½ü¿ô¤¬£°¤«¤É¤¦¤«³Îǧ¤¹¤ë
PRINT "£°¤Ç¤Ï³ä¤ì¤Þ¤»¤ó¡£"
STOP
END IF
FOR i=0 TO L2 !¾¦¤ò£°¤È¤¹¤ë
LET q(i)=0
NEXT i
LET v=b(bMSD) !ºÇ¾å°Ì·å¤ÎÃͤòÆÀ¤ë
LET nk=INT(RADIX/(v+1)) !b(MSD)¤òRADIX/2°Ê¾å¤Ë¤¹¤ë¤¿¤á¤ÎºÇ¾®·¸¿ô
IF nk>1 THEN
CALL lmul(b,nk, bb) !½ü¿ô¤ÎºÇ¾å°Ì·å¤òRADIX/2°Ê¾å¡¢RADIX̤Ëþ¤Ë¤¹¤ë
CALL lmul(a,nk, aa) !a¤ânkÇܤ¹¤ë
ELSE
CALL lcopy(b, bb) !¡ß£±
CALL lcopy(a, aa)
END IF
LET t=GetMSD(bb)
DO UNTIL lcomp(aa,bb)<0 !a<b¤Ê¤é½ªÎ»
LET s=GetMSD(aa)
IF aa(s)>=bb(t) THEN
IF CompareOffset(aa,bb,s-t)>=0 THEN !a>=b*RADIX^(s-t)¤ò¸¡ºº¤¹¤ë
LET u=s-t !¾¦¤ÎºÇ¾å°Ì·å°ÌÃÖu¤ª¤è¤ÓÃÍq(u)¤Î¸õÊä¤òµá¤á¤ë
LET q(u)=1
ELSE
LET u=s-t-1
LET q(u)=RADIX-1
END IF
ELSE
LET u=s-t-1
LET q(u)=INT( (aa(s)*RADIX+aa(s-1))/bb(t) )
END IF
CALL lmul(bb,q(u), m)
DO WHILE CompareOffset(aa,m,u)<0 !a>=m=b*q(0)¤òËþ¤¿¤¹ºÇÂç¤Îq(u)¤òµá¤á¤ë
LET q(u)=q(u)-1
CALL lmul(bb,q(u), m)
LOOP
CALL SubOffset(aa,m, u) !a=a-b*q(u)*RADIX^u
LOOP
IF nk>1 THEN
CALL ldiv(aa,nk, r) !;¤ê 1/nkÇÜ
ELSE
CALL lcopy(aa, r)
END IF
END SUB
EXTERNAL FUNCTION CompareOffset(a(),b(),n) !·å¤ò¤º¤é¤·¤ÆÈæ³Ó¤¹¤ë
LET aMSD=GetMSD(a)
LET bMSD=GetMSD(b)+n
IF aMSD>bMSD THEN
LET CompareOffset=1
ELSEIF aMSD<bMSD THEN
LET CompareOffset=-1
ELSE
FOR i=aMSD TO n STEP -1
IF a(i)>b(i-n) THEN
LET CompareOffset=1
EXIT FUNCTION
END IF
IF a(i)<b(i-n) THEN
LET CompareOffset=-1
EXIT FUNCTION
END IF
NEXT i
DO !a(aMSD)¡Áa(n)¤Èb(bMSD)¡Áb(0)¤¬°ìÃפ¹¤ë¾ì¹ç¡¢
IF NOT i>=0 THEN EXIT DO !a(n-1)¡Áa(0)¤ËÈóÎí¤Î¤â¤Î¤¬¤¢¤ì¤Ð¡¢a¤ÎÊý¤¬Â礤¤
IF a(i)<>0 THEN
LET CompareOffset=1
EXIT FUNCTION
END IF
LET i=i-1
LOOP
LET CompareOffset=0
END IF
END FUNCTION
EXTERNAL SUB SubOffset(a(),b(),n) !·å¤ò¤º¤é¤·¤Æ¸º»»¡¡¢¨a=a-b*RADIX^n
LET brrw=0 !¼Ú¤ê
LET bMSD=GetMSD(b) !ºÇ¾å°Ì·å¤Þ¤Çb¤ò¤Ò¤¯
FOR i=0 TO bMSD
LET d=a(i+n)-b(i)-brrw !Ʊ¤¸·å¤Ç
IF d>=0 THEN
LET a(i+n)=d
LET brrw=0
ELSE
LET a(i+n)=d+RADIX
LET brrw=1 !¾å¤Î·å¤«¤é¼Ú¤ê¤ë
END IF
NEXT i
DO !¾å°Ì·å¤Ø¤Î·å¼Ú¤ê
IF NOT brrw<>0 THEN EXIT DO
IF a(i+n)<>0 THEN
LET a(i+n)=a(i+n)-1
LET brrw=0
ELSE
LET a(i+n)=RADIX-1
LET brrw=1
END IF
LET i=i+1
LOOP
END SUB
END MODULE
!-------------------------------
OPTION ANGLE DEGREES
LET x=-2
LET y=0
LET z=0
LET a=0.398
LET b=2
LET c=4
!-----¥ì¥¹¥é¡¼ÊýÄø¼°( ÈóÀþ·Á¹à¤¬¡¢z*x £±¤Ä¤À¤±¤Î¥«¥ª¥¹)
DEF dxdt( y,z)=-y-z ! (dx/dt)= -y -z
DEF dydt(x,y )= x+a*y ! (dy/dt)= x +a*y
DEF dzdt(x ,z)= b+z*(x-c) ! (dz/dt)= b +z*(x-c)
SUB RungeKutta
LET kx1=dxdt( y,z)
LET ky1=dydt(x,y )
LET kz1=dzdt(x ,z)
!
LET kx2=dxdt( y+ky1*dt/2 ,z+kz1*dt/2)
LET ky2=dydt(x+kx1*dt/2, y+ky1*dt/2 )
LET kz2=dzdt(x+kx1*dt/2 ,z+kz1*dt/2)
!
LET kx3=dxdt( y+ky2*dt/2 ,z+kz2*dt/2)
LET ky3=dydt(x+kx2*dt/2, y+ky2*dt/2 )
LET kz3=dzdt(x+kx2*dt/2 ,z+kz2*dt/2)
!
LET kx4=dxdt( y+ky3*dt ,z+kz3*dt)
LET ky4=dydt(x+kx3*dt, y+ky3*dt )
LET kz4=dzdt(x+kx3*dt ,z+kz3*dt)
!
LET x=x+(kx1+2*kx2+2*kx3+kx4)*dt/6
LET y=y+(ky1+2*ky2+2*ky3+ky4)*dt/6
LET z=z+(kz1+2*kz2+2*kz3+kz4)*dt/6
END SUB
!-----run
SET TEXT background "OPAQUE"
SET COLOR MIX(15) .5,.5,.5
SET POINT STYLE 1
DIM vl(12),vr(12),vb(12),vt(12) ,va(12)
DATA .8, .8, .6, .4, .2, 0 , 0 , 0 , .2, .4, .6, .8
DATA 1 , 1 , .8, .6, .4, .2, .2, .2, .4, .6, .8, 1
DATA .4, .6, .8, .8, .8, .6, .4, .2, 0 , 0 , 0 , .2
DATA .6, .8, 1 , 1 , 1 , .8, .6, .4, .2, .2, .2, .4
DATA 0, 30, 60, 90,120,150,180,-150,-120,-90,-60,-30
MAT READ vl,vr,vb,vt,va
!
CLEAR
LET dt=.03 !±é»»¥Ô¥Ã¥Á sec. pitch time
LET t=0
DO
SET VIEWPORT .2, .8, .2, .8
SET WINDOW -7,7,-7,7! -4,6, -6,3
IF 0< t THEN
PLOT LINES:bakx,baky; x,y
ELSE
DRAW axes !grid(1,1)
FOR p=1 TO 12
PLOT LINES:0,0;8*COS(va(p)),8*SIN(va(p))
PLOT TEXT,AT 6.6*COS(va(p))-.15, 6.6*SIN(va(p))-.3 :STR$(va(p))
NEXT p
END IF
LET bakx=x
LET baky=y
CALL RungeKutta
FOR p=1 TO 12
IF ABS( va(p)-ANGLE(x,y))< 1 THEN
CALL poincare
END IF
NEXT p
LET t=t+dt
LOOP UNTIL 2000< t
SUB poincare
SET VIEWPORT vl(p),vr(p),vb(p),vt(p)
SET WINDOW -1,7,-1,7
!PLOT LINES:-1,-1;7,-1;7,7;-1,7;-1,-1
DRAW axes
PLOT POINTS: SQR(x^2+y^2),z
END SUB
!¡¡1129
!t=¦²1/k=1/1+1/2+1/3+ ¡Ä +1/1129
!¡¡k=1
LET t=0 !ÉôʬÏÂ
LET k=1
DO
LET t=t+1/k !t=¦²1/k
IF k=1129 THEN EXIT DO
LET k=k+1
LOOP
PRINT k
PRINT t !·ë²Ì
END
!ÎãÂ꣱¡¡¼«Á³¿ô¤ÎÏÂ
!¡¡def a(n)=n (n>=1)¡¡¢¨°ìÈ̹à
!¡¡t=¦²{a[k]; k=1,t>300}¡¡¢¨Ï¤¬300¤òĶ¤¨¤ë¤È¤¡¢ºÇ¾®¤Îk¤È¤½¤ÎϤòɽ¼¨¤¹¤ë
!¡¡print k,t
!
!¡¡¢¨µ¼»÷¸À¸ì¤Ë¤è¤ëɽ¸½
DEF a(n)=n !def a(n)=n (n>=1) ¤ÎÉôʬ
LET t=0 !¦²{a[k]; k=1,t>300} ¤ÎÉôʬ
LET k=1
DO
LET t=t+a(k)
IF t>300 THEN EXIT DO
LET k=k+1
LOOP
PRINT "k=";k, "t=";t !print k,t ¤ÎÉôʬ
!ÎãÂ꣱¤ÎÊ̲ò
FOR k=1 TO 300 !¾å¸Â¡¡¢è1+2+3+ ¡Ä +k
LET t=k*(k+1)/2 !Ϥθø¼° ¦²k
IF t>300 THEN EXIT FOR
NEXT k
PRINT "k=";k, t
!ÎãÂꣲ
!¡¡def2 y[1]=1, y[n+1]=3*y[n]+2 (n>=1)¡¡¢¨ÎÙÀÜÆó¹à´ÖÁ²²½¼°
!¡¡print y[n=1,10]¡¡¢¨£±¡Á10¹à¤òɽ¼¨¤¹¤ë
FUNCTION y(n) !def2 y[1]=1, y[n+1]=3*y[n]+2 (n>=1) ¤ÎÉôʬ
local k,y0,y1
LET y1=1 !<---
IF n=1 THEN !Â裱¹à
LET y=y1
ELSE
FOR k=2 TO n !Â裲¹à°Ê¹ß
LET y0=y1
LET y1=3*y0+2 !<---
NEXT k
LET y=y1
END IF
END FUNCTION
FOR n=1 TO 10 !print x[n=1,10] ¤ÎÉôʬ
PRINT n;y(n)
NEXT n
!!ÎãÂꣳ¡¡¥Õ¥£¥Ü¥Ê¥Ã¥Á¿ôÎó
!¡¡def3 x[1]=0, x[2]=1, x[n+2]=x[n+1]+x[n] (n>=1)¡¡¢¨ÎÙÀÜ»°¹à´ÖÁ²²½¼°
!¡¡for n=1 to n¡¡¢¨¼þ´ü¤Î¤¢¤ë¿ôÎó¤Ø
!¡¡¡¡print x[n] mod 4¡¡¢¨Í¾¤ê¤òɽ¼¨¤¹¤ë
!¡¡next
FUNCTION x(n) !def3 x[1]=1, x[2]=1, x[n+2]=x[n+1]+x[n] (n>=1) ¤ÎÉôʬ
local k,x0,x1,x2
LET x1=0 !<---
IF n=1 THEN !Â裱¹à
LET x=x1
ELSE
LET x2=1 !<---
IF n=2 THEN !Â裲¹à
LET x=x2
ELSE
FOR k=3 TO n !Â裳¹à°Ê¹ß
LET x0=x1
LET x1=x2
LET x2=x1+x0 !<---
NEXT k
LET x=x2
END IF
END IF
END FUNCTION
FOR n=1 TO 30
PRINT n; MOD(x(n+1),4) !print x[n] mod 4 ¤ÎÉôʬ
NEXT n
END
FUNCTION f(n)
IF n<2 THEN
LET f=n !f(0)=0, f(1)=1
ELSE
LET f=f(n-1)+f(n-2) !f(n)=f(n-1)+f(n-2) n¡æ2
END IF
END FUNCTION
FOR k=0 TO 30 !£±¡Á£³£°¹à¤òɽ¼¨¤¹¤ë
PRINT k;f(k)
NEXT k
END
!Àè¤Î¡¢²þÎÉÈÇ¡£
!
!³ÑÅÙ¤ÎÁë¤ò»ß¤á¡¢³ÑÅÙ¤ò±Û¤¨¤ë£±ÈÖÌܤǡ¢ºÎ¼è¤¹¤ë¡£(sens lead edge)
!ʸ¤ÏÆɤ߿ɤ¯¤Ê¤ë¤¬¡¢¥Ô¥Ã¥ÁÉý¹¤¯¤Æ¤â¡¢ºÎ¼è½ÐÍè¡¢¥Ô¥Ã¥ÁÉý¤Ë±þ¤¸¤¿
!¥Ü¥±¤Ë¤Ê¤ë¤¿¤á¡¢¥Ô¥Ã¥ÁÉý¤Î¡¢É¾²Á¤¬½ÐÍè¤ë¡£Â®Å٤⮤¤¡£
!-30¡ë(330¡ë)ÅÙÉÕ¶á¤Î¥Ü¥±¤¬¡¢¼è¤ì¤¿¡£
!¥ì¥¹¥é¡¼ÊýÄø¼°¡¢£³¼¡¸µ¥°¥é¥Õ¡¢Ãæ±û¤Î¿Þ¤Ï¡¢¾å¤«¤é¸«¤¿£ø£ùÊ¿ÌÌ¡£
!¼þ°Ï£³£°ÅÙ ¤´¤È¤ËÇÛÃÖ¤µ¤ì¤¿£±£²Ëç¤Î¿Þ¤Ï¡¢
!¤½¤Î³ÑÅ٤ǤΡ¢¥Ý¥¢¥ó¥«¥ìÀÚÃÇÌÌ( ½Ä:£ú¼´¡¢²£:Ãæ¿´¤«¤é¤Îµ÷Î¥)
!-------------------------------
LET x=-3
LET y=0
LET z=0
LET a=0.398
LET b=2
LET c=4
!-----¥ì¥¹¥é¡¼ÊýÄø¼°( ÈóÀþ·Á¹à¤¬¡¢z*x £±¤Ä¤À¤±¤Î¥«¥ª¥¹¡£·Á¾õ:¥á¥Ó¥¦¥¹¤ÎÂÓ)
DEF dxdt( y,z)=-y-z ! (dx/dt)= -y -z
DEF dydt(x,y )= x+a*y ! (dy/dt)= x +a*y
DEF dzdt(x ,z)= b+z*(x-c) ! (dz/dt)= b +z*(x-c)
SUB RungeKutta
LET kx1=dxdt( y,z)
LET ky1=dydt(x,y )
LET kz1=dzdt(x ,z)
!
LET kx2=dxdt( y+ky1*dt/2 ,z+kz1*dt/2)
LET ky2=dydt(x+kx1*dt/2, y+ky1*dt/2 )
LET kz2=dzdt(x+kx1*dt/2 ,z+kz1*dt/2)
!
LET kx3=dxdt( y+ky2*dt/2 ,z+kz2*dt/2)
LET ky3=dydt(x+kx2*dt/2, y+ky2*dt/2 )
LET kz3=dzdt(x+kx2*dt/2 ,z+kz2*dt/2)
!
LET kx4=dxdt( y+ky3*dt ,z+kz3*dt)
LET ky4=dydt(x+kx3*dt, y+ky3*dt )
LET kz4=dzdt(x+kx3*dt ,z+kz3*dt)
!
LET x=x+(kx1+2*kx2+2*kx3+kx4)*dt/6
LET y=y+(ky1+2*ky2+2*ky3+ky4)*dt/6
LET z=z+(kz1+2*kz2+2*kz3+kz4)*dt/6
END SUB
!-----run
SET TEXT background "OPAQUE"
SET COLOR MIX(15) .5,.5,.5
SET POINT STYLE 1
OPTION ANGLE DEGREES
OPTION BASE 0
DIM vl(11),vr(11),vb(11),vt(11) ,va(11)
DATA .8, .8, .6, .4, .2, 0 , 0 , 0 , .2, .4, .6, .8
DATA 1 , 1 , .8, .6, .4, .2, .2, .2, .4, .6, .8, 1
DATA .4, .6, .8, .8, .8, .6, .4, .2, 0 , 0 , 0 , .2
DATA .6, .8, 1 , 1 , 1 , .8, .6, .4, .2, .2, .2, .4
DATA 0, 30, 60, 90,120,150,180,210,240,270,300,330
MAT READ vl,vr,vb,vt,va
!
LET dt=.02 !sec. pitch time
LET t=0
DO
SET VIEWPORT .2, .8, .2, .8
SET WINDOW -7,7,-7,7
LET xya= MOD(ANGLE(x,y),360) !xya= 0~< 360 ¢« 0~180~(-180)< ~< 0
IF 0< t THEN
PLOT LINES: bakx,baky; x,y
ELSE
DRAW axes
FOR i=11 TO 0 STEP -1
PLOT LINES:0,0;8*COS(va(i)),8*SIN(va(i))
PLOT TEXT,AT 6.6*COS(va(i))-.15, 6.6*SIN(va(i))-.3 :STR$(va(i))
IF xya<=va(i) THEN LET p=i ! ½é´ü³ÑÅ٤Πva()ÈÖ¹æ ¤òõ¤¹¡£
NEXT i
END IF
!----
IF p=0 THEN
IF xya< va(1) THEN CALL poincare ! 0Å٤Πva() ¤Î¤ß¡£
ELSE
IF va(p)<=xya THEN CALL poincare ! 30~330Å٤Πva()
END IF
!----
LET bakx=x
LET baky=y
CALL RungeKutta
LET t=t+dt
LOOP UNTIL 1400< t
SUB poincare
SET VIEWPORT vl(p),vr(p),vb(p),vt(p)
SET WINDOW -1,7,-1,7
DRAW axes
PLOT POINTS: SQR(x^2+y^2),z
LET p=MOD(p+1,12) ! ¼¡¤Î va()ÈÖ¹æ
END SUB
! ºÆµ¢·¿¡£Ã¢¤·¡¢£Î²ó¸å¤ÎºÇ½ª¼ÌÁü¤«¤é¡¢N,,,2,1,0 µÕ½ç¤ÇÉÁ²è¤µ¤ì¤ë¡£
SUB fr(k, x,y)
IF 0< k THEN CALL fr(k-1, x1(x,y),y1(x,y))
PLOT POINTS: x,y
END SUB
! ¼ÌÁü¤Î½çÈ֤ɤ¦¤ê¤Ë¡¢0,1,2,,,N Àµ½çÈÖ¤ÇÉÁ²è¡£
SUB fo(N, x,y)
FOR k=0 TO N
PLOT POINTS: x,y
LET wx= x1(x,y) ! x= x1(x,y) ¢«ËÜÍè¤Ç¤¹¤¬¡¢x ¤ÎÊѲ½¤Ï¡¢¼¡¼°¤Î¸å¤Ë¡£
LET y= -x+F(wx) ! y= y1(x,y) ¢«ËÜÍè¤Ç¤¹¤¬¡¢wx ¤Ç·×»»¤ÎÀáÌó¡£
LET x=wx
NEXT k
END SUB
SET TEXT FONT "£Í£Ó ÌÀÄ«",12
SET TEXT BACKGROUND "OPAQUE"
SET POINT STYLE 1
LET N=50000
!
LET h=20
LET xm= h*0.1
LET ym= h*0.35
SET WINDOW xm-h,xm+h, ym-h,ym+h
CALL fo(N,.1,2) !¡¡¼ÌÁü¤ÎÀµ½ç¤ÇÉÁ²è 0,1,2,,,N
!
LET h=30
LET xm= h*0.2
LET ym=-h*0.4
SET WINDOW xm-h,xm+h, ym-h,ym+h
PLOT TEXT,AT xm-h*0.15, ym+h*0.85:t$& " N= "& STR$(N)
PLOT TEXT,AT xm-h*0.9, ym+h*0.85:"¤·¤Ð¤é¤¯¸æÂÔ¤Á²¼¤µ¤¤¡£"
CALL fr(N,.1,2) !¡¡ºÇ½ª¼ÌÁü¤«¤éµÕ½ç¤ÇÉÁ²è N,,,2,1,0
PLOT TEXT,AT xm-h*0.9, ym+h*0.85:"¡¡ÉÁ²è¤Î½ªÎ»¡¡¡¡¡¡¡¡¡¡"
(2) GRID(p,q),AXES(p,q)¤ÇÆÃÄê¤Î¿ôÃͤòÀßÄꤹ¤ë¤È±¦Ã¼,¾åü¤Î¿ô»ú¤¬ÉÁ¤«¤ì¤Ê¤¤¡£
10 LET a=23 ! a=41,46,51,82,87,92,97,¡Ä
20 LET b=1 ! b=2,4,8,11,13,16,21,22,26,27,¡Ä
30 SET WINDOW -a,a,-b,b
40 DRAW GRID(a/5,b/10)
50 END
(3) GRID(p,q),AXES(p,q)¤ÇyºÂɸ¤ÎÎΰè¤ÎÉý¤ò¤´¤¯¾®¤µ¤¯ÀßÄꤹ¤ë¤È¡¢ÉÁ¤«¤ì¤Ê¤¤¤Ï¤º¤Îx¼´¤Î¿ô»ú¤¬¾åü¤ËÉÁ²è¤µ¤ì¤ë¤³¤È¤¬¤¢¤ë¡£
10 LET c=.0000001
20 SET WINDOW -5,5,7-c,7
30 DRAW GRID(1,c/10)
40 END
SUB RungeKutta
LET kx1=dxdt(x,y )
LET ky1=dydt(x,y,z)
LET kz1=dzdt(x,y,z)
!
LET kx2=dxdt(x+kx1*dt/2, y+ky1*dt/2 )
LET ky2=dydt(x+kx1*dt/2, y+ky1*dt/2 ,z+kz1*dt/2)
LET kz2=dzdt(x+kx1*dt/2, y+ky1*dt/2 ,z+kz1*dt/2)
!
LET kx3=dxdt(x+kx2*dt/2, y+ky2*dt/2 )
LET ky3=dydt(x+kx2*dt/2, y+ky2*dt/2 ,z+kz2*dt/2)
LET kz3=dzdt(x+kx2*dt/2, y+ky2*dt/2 ,z+kz2*dt/2)
!
LET kx4=dxdt(x+kx3*dt, y+ky3*dt )
LET ky4=dydt(x+kx3*dt, y+ky3*dt ,z+kz3*dt)
LET kz4=dzdt(x+kx3*dt, y+ky3*dt ,z+kz3*dt)
!
LET x=x+(kx1+2*kx2+2*kx3+kx4)*dt/6
LET y=y+(ky1+2*ky2+2*ky3+ky4)*dt/6
LET z=z+(kz1+2*kz2+2*kz3+kz4)*dt/6
END SUB
!-----run
OPTION ANGLE DEGREES
DIM pV1(4), pV2(4), P3D(4,4), rotx(4,4)
MAT rotx=IDN
!
LET ax=-75 !¡¡¸¶ÅÀ¤òÄ̤ꡢ²èÌ̤οåÊ¿¼´¤Ç¤Î²óž¡Ê x ¼´¤È¤Ï¡¢¸Â¤é¤º¡£¡Ë
!
! 1, 0, 0, 0
! 0, cos(ax), 0, 0
! 0,-sin(ax), 1, 0
! 0, 0, 0, 1
!
LET rotx(2,2)=COS(ax)
LET rotx(3,2)=-SIN(ax)
!
LET xm=0
LET ym=20
LET h=40
SET WINDOW xm-h,xm+h,ym-h,ym+h
LET dt=.005 !sec. pitch time
!
FOR az=-45 TO 315 STEP 10 !¡¡£ú¼´¤Ç¤Î²óž¡£360 ÅÙ¡¢°ì²ó¤ê¡£
!----
LET x=2
LET y=1
LET z=24
!----
LET t=0
IF -45< az THEN SET DRAW mode hidden
CLEAR
PLOT TEXT,AT xm+h*.2,ym+h*.9 :"lorenz ¥í¡¼¥ì¥ó¥ÄÊýÄø¼°"
DO
IF 0< t THEN
!---3D ¶ÊÀþ(x,y,z)
DRAW line3D( bakx,baky,bakz, x,y,z) WITH ROTATE(az)*rotx
PLOT LINES: pV1(1),pV1(2); pV2(1),pV2(2)
ELSE
! ---X ¼´
DRAW line3D( -30,0,0, 30,0,0) WITH ROTATE(az)*rotx
PLOT LINES: pV1(1),pV1(2); pV2(1),pV2(2)
PLOT TEXT,AT pV2(1),pV2(2) :"(X)"
!---Y ¼´
DRAW line3D( 0,-30,0, 0,30,0) WITH ROTATE(az)*rotx
PLOT LINES: pV1(1),pV1(2); pV2(1),pV2(2)
PLOT TEXT,AT pV2(1),pV2(2) :"(Y)"
!---Z ¼´
DRAW line3D( 0,0,-10, 0,0,50) WITH ROTATE(az)*rotx
PLOT LINES: pV1(1),pV1(2); pV2(1),pV2(2)
PLOT TEXT,AT pV2(1),pV2(2) :"(Z)"
END IF
!----
LET bakx=x
LET baky=y
LET bakz=z
CALL RungeKutta
LET t=t+dt
LOOP UNTIL 30< t !¡¡100 ¤¯¤é¤¤¤¬Îɤ¤¤Î¤«¤â¡Ä¡¡ÃÙ¤¯¤Ê¤ë¡£
SET DRAW mode explicit
NEXT az
PICTURE line3D(x1,y1,z1, x2,y2,z2)
MAT P3D=TRANSFORM !¢« draw Ž¥Ž¥Ž¥ with matrix ¤ÇÍ¿¤¨¤é¤ì¤¿ matrix
LET pV1(1)=x1
LET pV1(2)=y1
LET pV1(3)=z1 !ÆþÎÏ z1 ºÂɸ¤Ï¡¢½ÐÎÏ x1,y1 ¤ËÈ¿±Ç¡¢ÉÁ²è¤µ¤ì¤ë¡£
LET pV1(4)=1
MAT pV1=pV1*P3D !½ÐÎÏ z1 ºÂɸpV1(3)¤Ï¡¢ÉÁ²è¤·¤Ê¤¤¡£
LET pV2(1)=x2
LET pV2(2)=y2
LET pV2(3)=z2 !ÆþÎÏ z2 ºÂɸ¤Ï¡¢½ÐÎÏ x2,y2 ¤ËÈ¿±Ç¡¢ÉÁ²è¤µ¤ì¤ë¡£
LET pV2(4)=1
MAT pV2=pV2*P3D !½ÐÎÏ z2 ºÂɸpV2(3)¤Ï¡¢ÉÁ²è¤·¤Ê¤¤¡£
END PICTURE
!¡¡ÈóÀþ·Á¹à¤¬¡¢z*x £±¤Ä¤À¤±¤Î¥«¥ª¥¹¡£·Á¾õ:¥á¥Ó¥¦¥¹¤ÎÂÓ
!-------------------------------
LET a=0.398
LET b=2
LET c=4
!-----¥ì¥¹¥é¡¼ÊýÄø¼°
SUB Dxyz( kx,ky,kz, x,y,z)
LET kx=-y-z ! (dx/dt)= -y -z
LET ky= x+a*y ! (dy/dt)= x +a*y
LET kz= b+z*(x-c) ! (dz/dt)= b +z*(x-c)
END SUB
SUB RungeKutta
CALL Dxyz( kx1,ky1,kz1, x,y,z)
CALL Dxyz( kx2,ky2,kz2, x+kx1*dt/2,y+ky1*dt/2,z+kz1*dt/2)
CALL Dxyz( kx3,ky3,kz3, x+kx2*dt/2,y+ky2*dt/2,z+kz2*dt/2)
CALL Dxyz( kx4,ky4,kz4, x+kx3*dt ,y+ky3*dt ,z+kz3*dt )
LET x=x+(kx1+2*kx2+2*kx3+kx4)*dt/6
LET y=y+(ky1+2*ky2+2*ky3+ky4)*dt/6
LET z=z+(kz1+2*kz2+2*kz3+kz4)*dt/6
END SUB
!-----run
OPTION CHARACTER byte !¥¦¥à¥é¥¦¥È"o" =CHR$(246) ¤ò¥¨¥é¡¼¤Ë¤µ¤»¤Ê¤¤¡£
OPTION ANGLE DEGREES
DIM pV(4), P3D(4,4), rotx(4,4)
!
MAT rotx=IDN !¡¡Ã±°Ì¹ÔÎó
LET ax=-55 !¡¡¸¶ÅÀ¤òÄ̤ꡢ²èÌ̤οåÊ¿¼´¤Ç¤Î²óž¡Ê x ¼´¤È¤Ï¡¢¸Â¤é¤º¡£¡Ë
!
!(x,y,z,1)| 1, 0, 0, 0 |¡¡PLOT ºÂɸ¥Ù¥¯¥È¥ë¤Ï¡¢¹Ô¥Ù¥¯¥È¥ë¡£
! | 0, cos(ax), 0, 0 |¡¡£´ÎóÌܤΣ±¤Ï¡¢³ÈÂçΨ¤ÎµÕ¿ô¤Ç¤¢¤ë¤¬¡¢
! | 0,-sin(ax), 1, 0 |¡¡draw ʸ¤Ç¡¢ÉÁ²è¤·¤Ê¤¤¤Î¤Ç¡¢Ìµ»ë¤·¤Æ²Ä¡£
! | 0, 0, 0, 1 |
!
LET rotx(2,2)=COS(ax)
LET rotx(3,2)=-SIN(ax)
!
LET xm=0
LET ym=2
LET h=7
SET WINDOW xm-h,xm+h,ym-h,ym+h
LET dt=.05 ! sec. pitch time
LET SS=35 ! £ú¼´²ó¤ê¡¢³«»Ï³ÑÅÙ
LET EE=SS-360 ! +360¡§º¸²óž¡¡-360¡§±¦²óž
!
FOR az=SS TO EE STEP SGN(EE-SS)*10 !¡¡£ú¼´¡¢°ì²ó¤ê360 ÅÙ
MAT P3D=ROTATE(az)*rotx
!----
IF az<>SS THEN SET DRAW mode hidden
CLEAR
SET TEXT font "Courier",11
PLOT TEXT,AT xm+h*.2,ym+h*.9 :"R"& CHR$(246)& "ssler"
SET TEXT font "ɸ½à¥´¥·¥Ã¥¯",11
PLOT TEXT,AT xm+h*.45,ym+h*.9 :"¥ì¥¹¥é¡¼ÊýÄø¼°" ! PEN-off
!---ºÂɸ¼´
CALL axes3D( -6,0,0, 6,0,0, "(X)" )
CALL axes3D( 0,-6,0, 0,6,0, "(Y)" )
CALL axes3D( 0,0,-2, 0,0,8, "(Z)" )
!---3D ¶ÊÀþ
LET x=-3
LET y=0
LET z=0
FOR t=0 TO 300 STEP dt
CALL line3D(x,y,z)
CALL RungeKutta
NEXT t
SET DRAW mode explicit
NEXT az
SUB axes3D(x1,y1,z1, x2,y2,z2, a$ )
CALL line3D(x1,y1,z1)
CALL line3D(x2,y2,z2)
PLOT TEXT,AT pV(1),pV(2) :a$ ! PEN-off
END SUB
SUB line3D(x,y,z)
LET pV(1)=x
LET pV(2)=y
LET pV(3)=z !ÆþÎÏ z ºÂɸ¤Ï¡¢½ÐÎÏ x,y ¤ËÈ¿±Ç¡¢ÉÁ²è¤µ¤ì¤ë¡£
MAT pV=pV*P3D
PLOT LINES: pV(1),pV(2); !½ÐÎÏ z ºÂɸpV(3)¤Ï¡¢ÉÔÍס£ PEN-on
END SUB
SUB Dxyz( kx,ky,kz, x,y,z)
LET kx= (gR*(y-x) -ih(x))/C1 ! (d vC1/dt)= (gR*(vC2-vC1)-ih(vC1))/C1
LET ky= (gR*(x-y) +z )/C2 ! (d vC2/dt)= (gR*(vC1-vC2)+iL )/C2
LET kz=
-y/L
! (d iL /dt)= -vC2/L
END SUB
!-----
SUB RungeKutta
CALL Dxyz( kx1,ky1,kz1, x,y,z)
CALL Dxyz( kx2,ky2,kz2, x+kx1*dt/2,y+ky1*dt/2,z+kz1*dt/2)
CALL Dxyz( kx3,ky3,kz3, x+kx2*dt/2,y+ky2*dt/2,z+kz2*dt/2)
CALL Dxyz( kx4,ky4,kz4, x+kx3*dt ,y+ky3*dt ,z+kz3*dt )
LET x=x+(kx1+2*kx2+2*kx3+kx4)*dt/6
LET y=y+(ky1+2*ky2+2*ky3+ky4)*dt/6
LET z=z+(kz1+2*kz2+2*kz3+kz4)*dt/6
END SUB
SUB graph3D
!-----run
!£ú¼´¤ò¡¢²èÌ̤οåÊ¿¼´¤Ç²óž¡¢·¹¤±¤ë¹ÔÎó rotx
!(x,y,z,1)| 1, 0, 0, 0 |¡¡½½¿Ê¤Î¡¢PLOT¥Ù¥¯¥È¥ë¤Ï¡¢¹Ô¥Ù¥¯¥È¥ë¡£
! | 0, cos(ax), 0, 0 |¡¡£´ÎóÌܤΣ±¤Ï¡¢³ÈÂçΨ¤ÎµÕ¿ô¤Ç¤¢¤ë¤¬¡¢
! | 0,-sin(ax), 1, 0 |¡¡draw~with~ ¤Ç¸ú²Ì¤¹¤ë¡£
! | 0, 0, 0, 1 |¡¡¤³¤Î¥×¥í¥°¥é¥à¤Ç¤Ï¡¢Ìµ»ë¤·¤Æ²Ä¡£
LET rotx(2,2)=COS(ax)
LET rotx(3,2)=-SIN(ax)
!
SET WINDOW xm-h,xm+h,ym-h,ym+h
!
FOR az=SS TO EE STEP SGN(EE-SS)*10 !¡¡£ú¼´¤Ç¡¢°ì²ó¤ê360 ÅÙ
MAT P3D=ROTATE(az)*rotx
!----
IF az<>SS THEN SET DRAW mode hidden
CLEAR
PLOT TEXT,AT xm-h*.8,ym+h*.9 :t$ !¡¡PEN-off
!---ºÂɸ¼´
CALL axes3D( LH(1),0,0, LH(2),0,0, "(X)" )
CALL axes3D( 0,LH(3),0, 0,LH(4),0, "(Y)" )
CALL axes3D( 0,0,LH(5), 0,0,LH(6), "(Z)" )
!---3D ¶ÊÀþ
IF az=SS THEN
LET n=0
FOR t=0 TO t99 STEP dt
LET copy(n,1)=x
LET copy(n,2)=y !¡¡£±²óÌÜ(³«»Ï³ÑÅÙ)¤Ç¡¢£³£ÄµÏ¿¤ò»£¤ë¡£
LET copy(n,3)=z
CALL line3D(x,y,z)
CALL RungeKutta
LET n=n+1
NEXT t
ELSE
FOR n=0 TO n-1
LET x=copy(n,1)
LET y=copy(n,2) !¡¡£²²óÌܰʹߤϡ¢µÏ¿¤ÎºÆÀ¸¤Ç¡¢¹â®ÉÁ²è¡£
LET z=copy(n,3)
CALL line3D(x,y,z)
NEXT n
END IF
SET DRAW mode explicit
NEXT az
END SUB
SUB axes3D(x1,y1,z1, x2,y2,z2, a$ )
CALL line3D(x1,y1,z1)
CALL line3D(x2,y2,z2)
PLOT TEXT,AT pV(1),pV(2) :a$ !¡¡PEN-off
END SUB
SUB line3D(x,y,z)
LET pV(1)=x
LET pV(2)=y
LET pV(3)=z !ÆþÎÏ z ºÂɸ¤Ï¡¢½ÐÎÏ x,y ¤ËÈ¿±Ç¡¢ÉÁ²è¤µ¤ì¤ë¡£
MAT pV=pV*P3D
PLOT LINES: pV(1),pV(2); !½ÐÎÏ z ºÂɸpV(3)¤Ï¡¢ÉÔÍס£ PEN-on
END SUB
SUB Dxyzn( kx,ky,kz,kn, x,y,z,n)
LET kx= I(t)-120*y^3*z*(x-115) -40*n^4*(x+12) -.24*(x-10.613) ! (d V/dt)
LET ky= .1*(25-x)/(EXP((25-x)/10)-1)*(1-y) -4*EXP(-x/18)*y ! (d m/dt)
LET kz= .07*EXP(-x/20)*(1-z)
-1/(EXP((30-x)/10)+1)*z !
(d h/dt)
LET kn= .01*(10-x)/(EXP((10-x)/10)-1)*(1-n) -.125*EXP(-x/80)*n! (d n/dt)
END SUB
LET I0=20 !ËìÅÅή ¥Ñ¥é¥á¡¼¥¿¡¼
LET A=40
LET f=.3000001
!
LET x=6.24 !½é´üÃÍ x,y,z,n
LET y=.0761
LET z=.301
LET n=.519
!
DATA -15,100, -.3,1, -.04,.49 !ºÂɸ¼´¤ÎξüºÂɸ xL,xH, yL,yH, zL,zH
MAT READ LH
LET Sx=1 !¥¹¥±¡¼¥ëÇÜΨ Sx,Sy,Sz
LET Sy=50
LET Sz=200
!
LET xm=40 !²èÌÌÃæ¿´ xm,ym
LET ym=52
LET hw=80 !²èÌÌÉý/2 ¡Þhw
LET dt=.05 ! pitch time
LET t99=500 ! close time
LET zox=40 !£ú¼´¤È¡¢Ê¿¹Ô¤Ê²óž¼´¤Ø¤Î¥ª¥Õ¥»¥Ã¥È£ø£ù
LET zoy=20
LET ax=-75 !²óž¼´¤ò¡¢²èÌ̤οåÊ¿¼´¤ÇÅݤ·¡¢·¹¤±¤ë³ÑÅÙ
LET SS=-25 !²óž ³«»Ï³ÑÅÙ
LET EE=SS+360 !²óž ½ªÎ»³ÑÅÙ +360¡§º¸²óž¡¡-360¡§±¦²óž
CALL graph3D
!-----
SUB RungeKutta
CALL Dxyzn( kx1,ky1,kz1,kn1, x,y,z,n)
CALL Dxyzn( kx2,ky2,kz2,kn2, x+kx1*dt/2,y+ky1*dt/2,z+kz1*dt/2,n+kn1*dt/2)
CALL Dxyzn( kx3,ky3,kz3,kn3, x+kx2*dt/2,y+ky2*dt/2,z+kz2*dt/2,n+kn2*dt/2)
CALL Dxyzn( kx4,ky4,kz4,kn4, x+kx3*dt ,y+ky3*dt ,z+kz3*dt ,n+kn3*dt )
LET x=x+(kx1+2*kx2+2*kx3+kx4)*dt/6
LET y=y+(ky1+2*ky2+2*ky3+ky4)*dt/6
LET z=z+(kz1+2*kz2+2*kz3+kz4)*dt/6
LET n=n+(kn1+2*kn2+2*kn3+kn4)*dt/6
END SUB
SUB graph3D
!-----run
!²óž¼´¤ò¡¢²èÌ̤οåÊ¿¼´¤ÇÅݤ·¡¢·¹¤±¤ë¹ÔÎó rotx
!(x,y,z,1)| 1, 0, 0, 0 |¡¡½½¿Ê¤Î¡¢PLOT¥Ù¥¯¥È¥ë¤Ï¡¢¹Ô¥Ù¥¯¥È¥ë¡£
! | 0, cos(ax), 0, 0 |¡¡£´ÎóÌܤΣ±¤Ï¡¢³ÈÂçΨ¤ÎµÕ¿ô¡¢drawʸ ¤Ç¸ú²Ì¡£
! | 0,-sin(ax), 1, 0 |¡¡Ä¾ÀܤΠplot lines ¤Ç¤Ï¡¢1 ¤Ë¥ê¥»¥Ã¥È¤µ¤ì¤ë¡£
! | 0, 0, 0, 1 |¡¡¹ÔÎó¤Î·×»»¤Ç¤Ï¡¢Ê¿¹Ô°ÜÆ°¤ò¡¢²Äǽ¤Ë¤¹¤ë¡£
LET rotx(2,2)=COS(ax) !¤³¤Î¥×¥í¥°¥é¥à¤Ç¤Ï¡¢SHIFT(,) ¤ÇɬÍס£
LET rotx(3,2)=-SIN(ax)
!
SET WINDOW xm-hw,xm+hw,ym-hw,ym+hw
!
FOR az=SS TO EE STEP SGN(EE-SS)*10 !¡¡²óž¼´¤Ç¡¢10 Å٤ŤIJ󤹡£
MAT P3D=SHIFT(-zox,-zoy)*ROTATE(az)*SHIFT(zox,zoy)*rotx
!----
IF az<>SS THEN SET DRAW mode hidden
CLEAR
PLOT TEXT,AT xm-hw*.9,ym+hw*.90 :t$
PLOT TEXT,AT xm-hw*.9,ym+hw*.83 :t2$
PLOT TEXT,AT xm-hw*.9,ym-hw*.92 :t5$
PLOT TEXT,AT xm-hw*.9,ym-hw*.99 :t4$& "¡¡¡¡"& t3$ !¡¡PEN-off
!---ºÂɸ¼´
CALL axes3D( LH(1),0,0, LH(2),0,0, STR$(LH(2))& "( X)" )
CALL axes3D( 0,LH(3),0, 0,LH(4),0, STR$(LH(4))& "( Y)" )
CALL axes3D( 0,0,LH(5), 0,0,LH(6), STR$(LH(6))& "( Z)" )
!---3D ¶ÊÀþ
IF az=SS THEN
LET ci=0
FOR t=0 TO t99 STEP dt
LET copy(ci,1)=x
LET copy(ci,2)=y !¡¡£±²óÌÜ(³«»Ï³ÑÅÙ)¤Ç¡¢£³£ÄµÏ¿¤ò»£¤ë¡£
LET copy(ci,3)=z
! PRINT x;y;z;n !¡¡¥Ç¡¼¥¿¡¼¤òÊݸ¤·¤¿¤¤»þ¡£
CALL line3D(x,y,z)
CALL RungeKutta
LET ci=ci+1
NEXT t
ELSE
FOR ci=0 TO ci-1 !¡¡£²²óÌܰʹߤϡ¢µÏ¿¤ÎºÆÀ¸¤Ç¡¢¹â®ÉÁ²è¡£
CALL line3D( copy(ci,1),copy(ci,2),copy(ci,3) )
NEXT ci
END IF
SET DRAW mode explicit
NEXT az
END SUB
SUB axes3D(x1,y1,z1, x2,y2,z2, a$ )
CALL line3D(x1,y1,z1)
CALL line3D(x2,y2,z2)
PLOT TEXT,AT pV(1),pV(2) :a$ !¡¡PEN-off
END SUB
SUB line3D(x,y,z)
LET pV(1)=x*Sx !ÉÁ²èÌÜÀ¹¤Ï¡¢Á´Êý¸þÅù¤·¤¯¤Ê¤¤¤È¡¢²óž¤Ç¡¢·Á¤¬ÊݤƤʤ¤¡£
LET pV(2)=y*Sy !¥¹¥±¡¼¥ë Sx,Sy,Sz ¤Î°ã¤¤¤Ï¡¢ÆþÎϤÎÇÜΨ¤È¤·¤Æ¡¢¹Ô¤Ê¤¦¡£
LET pV(3)=z*Sz !ÆþÎÏ z ºÂɸ¤Ï¡¢½ÐÎÏ x,y ¤ËÈ¿±Ç¡¢ÉÁ²è¤µ¤ì¤ë¡£
MAT pV=pV*P3D
PLOT LINES: pV(1),pV(2); !¡¡PEN-on
END SUB
10 LET c=.0000001
20 SET WINDOW -5,5,7-c,7
30 DRAW GRID2(1,c/10) ! <-----
40 END
50 MERGE "grid2.lib" ! <-----¡¡¢¨EXTERNAL PICTURE ʸ¤Ë¤è¤ëľÀܤε½Ò¤âOK
¤Þ¤¿¡¢DRAW circle¡¢DRAW disk ¤Ë¤Ä¤¤¤Æ¤âƱ¤¸¸½¾Ý¤¬È¯À¸¤¹¤ë¡£
SET WINDOW -500,500,-500,500
LET phi=(1+SQR(5))/2 !²«¶âÈæ
LET a=2*PI*phi !²«¶â³Ñ
LET r=1
LET th=0
FOR i=0 TO 900
LET r=1.1*r !¤é¤»¤ó¾õ
LET th=th+a
LET x1=r*COS(th)
LET y1=r*SIN(th)
!DRAW disk WITH SCALE(r*0.3)*SHIFT(x1,y1)
DRAW circle WITH SCALE(r*0.3)*SHIFT(x1,y1)
NEXT i
END
MERGE "circle.lib"
!¡ü¤½¤Î£±¡¡1¡åp^2¡ån¡¢1¡åq¡ån¤òËþ¤¿¤¹p,q¤ÎÀѤ¬¡¢¼°n=p^2*q¤òËþ¤¿¤¹
LET n=324
FOR p=INT(SQR(n)) TO 1 STEP -1 !p^2¤Î¸õÊä
LET x=p^2
FOR q=1 TO n !q¤Î¸õÊä
!FOR q=1 TO n/x !q¤Î¸õÊä¡¡¢¨q=n/p^2¤è¤ê
IF x*q=n THEN !¼°¤òËþ¤¿¤¹
PRINT "p=";p; "q=";q
END IF
NEXT q
NEXT p
!¡ú¤½¤Î£²¡Ý£±¡¡n=p^2*q¤è¤ê¡¢p^2¤Ïn¤ÎÌó¿ô¡Ên¤Ïp^2¤ÎÇÜ¿ô¡Ë
LET n=324
FOR p=INT(SQR(n)) TO 1 STEP -1 !¸õÊä¤òÂ礤¤Êý¤«¤é
LET x=p^2
IF MOD(n,x)=0 THEN !p^2¤Ïn¤ÎÌó¿ô¤è¤ê
!IF INT(n/x)*x=n THEN !n¤Ïp^2¤ÎÇÜ¿ô¤è¤ê
LET q=n/x
PRINT "p=";p; "q=";q
END IF
NEXT p
!¡ü¤½¤Î£²¡Ý£²¡¡n=p^2*q¤è¤ê¡¢q¤Ïn¤ÎÌó¿ô¡Ên¤Ïq¤ÎÇÜ¿ô¡Ë
LET n=324
FOR q=1 TO n !¸õÊä¤ò¾®¤µ¤¤Êý¤«¤é
IF MOD(n,q)=0 THEN !q¤Ïn¤ÎÌó¿ô¤è¤ê
!IF INT(n/q)*q=n THEN !n¤Ïq¤ÎÇÜ¿ô¤è¤ê
LET p=SQR(n/q)
IF p=INT(p) THEN !p¤Ï¼«Á³¿ô
PRINT "p=";p; "q=";q
END IF
END IF
NEXT q
!¡ú¤½¤Î£³¡Ý£±¡¡n=p^2*q¤è¤ê¡¢q¤Î£±¼¡ÊýÄø¼°q=n/p^2¤ò²ò¤¯
LET n=324
FOR p=INT(SQR(n)) TO 1 STEP -1 !Ìó¿ôp^2¤Î¸õÊä¤òÂ礤¤Êý¤«¤é
LET q=n/p^2
IF q=INT(q) THEN !q¤Ï¼«Á³¿ô¤è¤ê
PRINT "p=";p; "q=";q
END IF
NEXT p
!¡ü¤½¤Î£³¡Ý£²¡¡n=p^2*q¤è¤ê¡¢p¤Î£²¼¡ÊýÄø¼°p^2=n/q¤ò²ò¤¯
LET n=324
FOR q=1 TO n !Ìó¿ôq¤Î¸õÊä¤ò¾®¤µ¤¤Êý¤«¤é
LET x=n/q
IF x=INT(x) THEN !p¤Ï¼«Á³¿ô¤è¤ê¡¢x=n/q=p^2¤Ï¼«Á³¿ô
LET p=SQR(x)
IF p=INT(p) THEN !ƱÍͤˡ¢p=SQR(n/q)¤Ï¼«Á³¿ô
PRINT "p=";p; "q=";q
END IF
END IF
NEXT q
!¡ú¤½¤Î£´¡¡ÁÇ°ø¿ôʬ²ò¡¡n=2^a*3^b*5^c* ¡Ä¤È¤¹¤ë¤È¡¢a=INT(a/2)*2+MOD(a,2)¡¢b,c,¡Ä¤âƱÍÍ
LET n=324
LET p=1
LET q=1
LET x=n
LET m=2
DO WHILE x>1 !£±¤Þ¤Ç·«¤êÊÖ¤¹
LET K=0
DO WHILE MOD(x,m)=0 !m¤Ç³ä¤êÀÚ¤ì¤ë¤Ê¤é¡Êm¤Ï°ø¿ô¡Ë
LET x=x/m !³ä¤êÀÚ¤ì¤ë¤Þ¤Ç¡Êm^K¤Î·Á¡Ë
LET K=K+1
LOOP
PRINT m;"^";K !debug
LET p=p*m^INT(K/2) !¾¦
LET q=q*m^MOD(K,2) !;¤ê
IF m>2 THEN !2,3,5,7,9,¡¦¡¦¡¦¤ÇÄ´¤Ù¤ë
LET m=m+2
ELSE
LET m=m+1
END if
LOOP
PRINT "p=";p; "q=";q
END
!Ê¿Êýº¬¤Î·×»»
!p*SQR(q)¤ò¡¢¡ÖSQR(q)¤È¤½¤Î·¸¿ôp¡×¤È¤·¤Æ¡¢ÇÛÎóa(q)=p¤Çɽ¤»¤ë¡£
!¢èn=p^2*q¡¢n,p,q¡æ0¤È¤¹¤ë¤È¡¢SQR(n)=p*SQR(q)¤ÈÊÑ·Á¤Ç¤¤ë¡£
!¡¡¤³¤ì¤è¤ê¡¢SQR(32)=4*SQR(2)¤È¤Ê¤ê¡¢Æ±Îà¹à¤ò¤Þ¤È¤á¤ë¾ì¹ç¡¢¶¦Ä̹àSQR(2)¤È¤·¤Æ°·¤¨¤ë¡£
!¡¡¤Þ¤¿¡¢SQR()¤òÇÛÎó¤È¤·¤Æ²ò¼á¤¹¤ë¤È¡¢SQR(n)¤ò°ì°Õ¤Ëɽ¸½¤Ç¤¤ë¡£
LET szRt=10 !°·¤¦Ê¿Êýº¬¤ÎÈÏ°Ï¡¡¢¨É¬Íפ˱þ¤¸¤ÆÊѹ¹¤Î¤³¤È
!±é»»´ØÏ¢
SUB SqSet(n, a()) !a=SQR(n)¤È¤¹¤ë
IF INT(n)<>n THEN
PRINT "À°¿ô¤òÀßÄꤷ¤Æ¤¯¤À¤µ¤¤¡£"; n
STOP
END IF
MAT a=ZER
CALL SqNormalize(ABS(n), p,q)
IF n<0 THEN LET q=-q
LET a(q)=p
END SUB
SUB SqSetQ(x,y, a()) !a=SQR(x/y)¡¢x:À°¿ô¡¢y:Àµ¤ÎÀ°¿ô ¤È¤¹¤ë
IF y<=0 OR INT(y)<>y THEN
PRINT "Àµ¤ÎÀ°¿ô¤òÀßÄꤷ¤Æ¤¯¤À¤µ¤¤¡£"; y
STOP
END IF
CALL SqSet(x*y, a)
CALL SqDivN(a,y, a)
END SUB
SUB SqSetN(n, a()) !a=n¤È¤¹¤ë
MAT a=ZER
LET a(1)=n
END SUB
SUB SqAdd(a(),b(), c()) !²Ã»» c=a+b
MAT c=a+b
END SUB
SUB SqSub(a(),b(), c()) !¸º»» c=a-b
MAT c=a-b
END SUB
SUB SqMulN(a(),N, c()) !¾è»» c=a*N¡¡¢¨{¢å(x)+¢å(y)+ ¡Ä }*N
MAT c=(N)*a
END SUB
SUB SqDivN(a(),N, c()) !½ü»» c=a/N¡¡¢¨{¢å(x)+¢å(y)+ ¡Ä }/N
IF N=0 THEN
PRINT "£°¤Ç¤Ï³ä¤ì¤Þ¤»¤ó¡£"
STOP
END IF
MAT c=(1/N)*a
END SUB
DIM w(-szRt TO szRt) !ºî¶ÈÍÑ
SUB SqMulS(a(),B, c()) !¾è»» c=a*B¡¡¢¨{¢å(x)+¢å(y)+ ¡Ä }*¢å(B)
MAT w=ZER
FOR i=LBOUND(a) TO UBOUND(a)
IF a(i)<>0 THEN !·¸¿ô¤¬£°°Ê³°¤Ê¤é
IF i*B<0 THEN
CALL SqNormalize(ABS(i*B), p,q) !¢¨¢å(-a)*¢å(b)=¢å(-a*b)¡¢¢å(a)*¢å(-b)=¢å(-a*b)
LET q=-q
ELSE
CALL SqNormalize(i*B, p,q) !¢¨¢å(a)*¢å(b)=¢å(a*b)
IF B<0 THEN LET p=-p !¢¨¢å(-a)*¢å(-b)=-¢å(a*b)
END IF
LET w(q)=w(q)+a(i)*p !¢å(a[])*¢å(B)
END IF
NEXT i
MAT c=w
END SUB
SUB SqDivS(a(),B, c()) !½ü»» c=a/B¡¡¢¨{¢å(x)+¢å(y)+ ¡Ä }/¢å(B)
IF B=0 THEN
PRINT "£°¤Ç¤Ï³ä¤ì¤Þ¤»¤ó¡£"
STOP
END IF
CALL SqMulS(a,B, c) !¢å(i)*¢å(B)/B¡¡¢¨Ê¬Êì¤òÍÍý²½¤¹¤ë
CALL SqDivN(c,B, c)
END SUB
DIM w0(-szRt TO szRt),w1(-szRt TO szRt) !ºî¶ÈÍÑ
SUB SqMul(a(),b(), c()) !¾è»» c=a*b¡¡¢¨{¢å(x)+¢å(y)+ ¡Ä }*{¢å(u)+¢å(v)+ ¡Ä }
MAT w0=ZER
FOR k=LBOUND(b) TO UBOUND(b)
LET Bk=b(k) !¢å(a[])*¢å(b[k])
IF Bk<>0 THEN !·¸¿ô¤¬£°°Ê³°¤Ê¤é
CALL SqMulS(a,k, w1) !Ê¿Êýº¬¤ÎÃæ¤ÎÉôʬ
CALL SqMulN(w1,Bk, w1) !·¸¿ô¤ÎÉôʬ
MAT w0=w0+w1
END IF
NEXT k
MAT c=w0
END SUB
DIM w2(-szRt TO szRt),w3(-szRt TO szRt),w4(-szRt TO szRt),w5(-szRt TO szRt) !ºî¶ÈÍÑ
SUB SqDiv(a(),b(), c()) !½ü»» c=a/b¡¡¢¨{¢å(x)+¢å(y)+ ¡Ä }/{¢å(u)+¢å(v)+ ¡Ä }
MAT w2=a
MAT w3=b
DO
FOR k=LBOUND(b) TO UBOUND(b) !Ê¿Êýº¬¤òõ¤¹
IF k<>1 AND w3(k)<>0 THEN EXIT FOR
NEXT k
IF k>UBOUND(b) THEN EXIT DO !Ê¿Êýº¬¤¬¤Ê¤¯¤Ê¤ì¤Ð¡¢ÍÍý²½¤ò½ªÎ»¤¹¤ë
MAT w4=w3 !{¢å(u)+¢å(v)+ ¡Ä }-¢å(k)¤ò¤Ä¤¯¤Ã¤Æ¡¢(s+t)*(s-t)=s^2-t^2¤Î·Á¤Ø
LET w4(k)=-w3(k)
CALL SqMul(w2,w4, w5) !ʬ»Ò¦¡¡{¢å(x)+¢å(y)+ ¡Ä }*{¢å(u)+¢å(v)+ ¡Ä -¢å(k)}
MAT w2=w5
CALL SqMul(w3,w4, w5) !ʬÊ즡¡{{¢å(u)+¢å(v)+ ¡Ä }+¢å(k)}*{{¢å(u)+¢å(v)+ ¡Ä }-¢å(k)}
MAT w3=w5
LOOP
CALL SqDivN(w2,w3(1), c) !ʬ»Ò/ʬÊì
END SUB
SUB SqPow(a(),n, x()) !¤Ù¤¾è x=a^n¡¡¢¨{¢å(x)+¢å(y)+ ¡Ä }^n
IF INT(n)<>n THEN
PRINT "¤Ù¤¾è¿ô¤¬À°¿ô¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£"; n
STOP
END IF
CALL SqSetN(1, w3) !x=1
MAT w2=a !b=a
LET n2=ABS(n)
DO UNTIL n2=0
IF MOD(n2,2)=1 THEN CALL SqMul(w3,w2, w3) !x=x*b
CALL SqMul(w2,w2, w2) !b=b*b
LET n2=INT(n2/2)
LOOP
IF n<0 THEN !Éé¤Ê¤éµÕ¿ô¤Ë¤¹¤ë
CALL SqSetN(1, w2)
CALL SqDiv(w2,w3, w3) !x=1/x
END IF
MAT x=w3
END SUB
SUB SqNormalize(n, p,q) !Ê¿Êýº¬¤ÎÃæ¤ò¤Ç¤¤ë¤À¤±¾®¤µ¤ÊÀµ¤ÎÀ°¿ô¤Ëľ¤¹
!¢¨n=p^2*q¡¢n,p,q¡æ0¤È¤¹¤ë¤È¡¢SQR(n)=p*SQR(q)¤ÈÊÑ·Á¤Ç¤¤ë¡£
LET q=1 !¢¨SQR(0)=0*SQR(1)¤È¤¹¤ë¡¡¢¨n=0¤Ê¤é¡¢£±¹Ô²¼¤ÎFORʸ¤Çp=0¤ÏÀßÄꤵ¤ì¤ë
FOR p=INT(SQR(n)) TO 1 STEP -1 !Ìó¿ôp^2¤Î¸õÊä¤òÂ礤¤Êý¤«¤é
!FOR p=INTSQR(n) TO 1 STEP -1 !Ìó¿ôp^2¤Î¸õÊä¤òÂ礤¤Êý¤«¤é¡¡¢¨ÍÍý¿ô¥â¡¼¥É¤Î¤È¤
LET q=n/p^2
IF q=INT(q) THEN EXIT FOR !q¤Ï¼«Á³¿ô¤è¤ê
NEXT p
END SUB
!½ÐÎÏ´ØÏ¢
SUB SqPrint(a()) !¢å(x)+¢å(y)+ ¡Ä ·Á¼°¤Çɽ¼¨¤¹¤ë
LET flg=0
FOR i=LBOUND(a) TO UBOUND(a) !¾®¤µ¤¤½ç¤Ë
LET Ai=a(i) !·¸¿ô
IF Ai<>0 THEN
IF flg=1 THEN PRINT " + "; !·Ñ³¤Ê¤é
IF Ai<0 THEN
PRINT "( ";Ai;") ";
ELSE
IF i=1 OR Ai<>1 THEN PRINT Ai; !·¸¿ô¤¬£±°Ê³°¤Ê¤é
END IF
IF i<>1 THEN !SQR(1)°Ê³°¤Ê¤é
IF Ai<>1 THEN PRINT "* "; !·¸¿ô¤¬£±°Ê³°¤Ê¤é
PRINT "SQR(";i;")";
END IF
LET flg=1
END IF
NEXT i
IF flg=0 THEN PRINT " 0";
PRINT
END SUB
!------------------------------ ¤³¤³¤Þ¤Ç¤¬¥µ¥Ö¥ë¡¼¥Á¥ó
DIM T1(-szRt TO szRt),T2(-szRt TO szRt),T3(-szRt TO szRt) !ºî¶ÈÍÑ
!¡üÎ㣱¡¡SQR(32)-SQR(3)*{2*SQR(2)+SQR(6)}+12/SQR(6) ¤Î·×»»
DIM c2(-szRt TO szRt),c3(-szRt TO szRt),c6(-szRt TO szRt),c32(-szRt TO szRt) !Äê¿ô
CALL SqSet(32, c32) !c32=SQR(32)
CALL SqSet(3, c3) !c3=SQR(3)
CALL SqSet(2, c2) !c2=SQR(2)
CALL SqSet(6, c6) !c6=SQR(6)
CALL SqMulN(c2,2, T1) !T1=2*SQR(2)
CALL SqAdd(T1,c6, T1) !T1=2*SQR(2)+SQR(6)
!CALL SqPrint(T1)
CALL SqMul(c3,T1, T3) !T3=SQR(3)*{2*SQR(2)+SQR(6)}
!!!¤Þ¤¿¤Ï¡¢CALL SqMulS(T1,3, T3) !T3=SQR(3)*{2*SQR(2)+SQR(6)}
!CALL SqPrint(T3)
CALL SqSub(c32,T3, T1) !T1=SQR(32)-SQR(3)*{2*SQR(2)+SQR(6)}
DIM n12(-szRt TO szRt) !Äê¿ô
CALL SqSetN(12, n12) !n12=12
CALL SqDivS(n12,6, T2) !T2=12/SQR(6)
!CALL SqPrint(T2)
CALL SqAdd(T1,T2, T1) !T1=SQR(32)-SQR(3)*{2*SQR(2)+SQR(6)}+12/SQR(6)
CALL SqPrint(T1) !·ë²Ì
!¡üÎ㣲 (-5+SQR(-9))/(3-SQR(-4)) ¤Î·×»»
DIM n3(-szRt TO szRt),nm5(-szRt TO szRt) !Äê¿ô
CALL SqSetN(3, n3) !n3=3
CALL SqSetN(-5, nm5) !nm5=-5
DIM cm4(-szRt TO szRt),cm9(-szRt TO szRt) !Äê¿ô
CALL SqSet(-4, cm4) !cm4=SQR(-4)
CALL SqSet(-9, cm9) !cm9=SQR(-9)
CALL SqAdd(nm5,cm9, T1) !T1=-5+SQR(-9)
CALL SqSub(n3,cm4, T2) !T2=3-SQR(-4)
CALL SqDiv(T1,T2, T3) !T3=(-5+SQR(-9))/(3-SQR(-4))
CALL SqPrint(T3) !·ë²Ì
END
SET WINDOW -5,5,-5,5
DRAW grid2(0,1)
END
EXTERNAL PICTURE grid2(p,q)
ASK WINDOW x1,x2,y1,y2
IF p<>0 THEN LET a=p ELSE LET a=2*(ABS(x1)+ABS(x2))
IF q<>0 THEN LET b=q ELSE LET b=2*(ABS(y1)+ABS(y2))
DRAW GRID(a,b)
END PICTURE
SUB Dxyzn( kx,ky,kz,kn, x,y,z,n)
LET kx= I(t)-120*y^3*z*(x-115) -40*n^4*(x+12) -.24*(x-10.613) ! (d V/dt)
LET ky= .1*(25-x)/(EXP((25-x)/10)-1)*(1-y) -4*EXP(-x/18)*y ! (d m/dt)
LET kz= .07*EXP(-x/20)*(1-z)
-1/(EXP((30-x)/10)+1)*z !
(d h/dt)
LET kn= .01*(10-x)/(EXP((10-x)/10)-1)*(1-n) -.125*EXP(-x/80)*n! (d n/dt)
END SUB
LET I0=20 !ËìÅÅή ¥Ñ¥é¥á¡¼¥¿¡¼
LET A=40
LET f=.3000001
!
LET x=6.24 !½é´üÃÍ x,y,z,n
LET y=.0761
LET z=.301
LET n=.519
LET dt=.05 !RungeKutta pitch time
LET t99=500 !RungeKutta close time
DATA -15,100, -.3,1, -.04,.45 !ºÂɸ¼´¤ÎξüºÂɸ xL,xH, yL,yH, zL,zH
MAT READ LH
LET zox=35 !²óž Àû²óÃæ¿´ÅÀ center ¤Ø¤Î¥ª¥Õ¥»¥Ã¥È£ø£ù£ú
LET zoy=.6
LET zoz=.2
!
LET Sx=1 !¥¹¥±¡¼¥ëÇÜΨ Sx,Sy,Sz
LET Sy=50
LET Sz=200
LET xm=35 !²èÌÌÃæ¿´ xm,ym
LET ym=35
LET hw=80 !²èÌÌÉý/2 ¡Þhw
!
LET ax=-75 !£ú¼´¤ò£ø¼´¤ÇÅݤ¹³«»Ï³ÑÅÙ
LET ay=0 !£ú¼´¤ò£ù¼´¤ÇÅݤ¹³«»Ï³ÑÅÙ
LET SS=0 !£ú¼´ ²óž³«»Ï³ÑÅÙ
LET ST= +5 !£ú¼´ ²óž¥¹¥Æ¥Ã¥×¡¡+¡§º¸²óž¡¡-¡§±¦²óž
!
SET WINDOW xm-hw,xm+hw,ym-hw,ym+hw
CALL graph3D
!-----
SUB RungeKutta
CALL Dxyzn( kx1,ky1,kz1,kn1, x,y,z,n)
CALL Dxyzn( kx2,ky2,kz2,kn2, x+kx1*dt/2,y+ky1*dt/2,z+kz1*dt/2,n+kn1*dt/2)
CALL Dxyzn( kx3,ky3,kz3,kn3, x+kx2*dt/2,y+ky2*dt/2,z+kz2*dt/2,n+kn2*dt/2)
CALL Dxyzn( kx4,ky4,kz4,kn4, x+kx3*dt ,y+ky3*dt ,z+kz3*dt ,n+kn3*dt )
LET x=x+(kx1+2*kx2+2*kx3+kx4)*dt/6
LET y=y+(ky1+2*ky2+2*ky3+ky4)*dt/6
LET z=z+(kz1+2*kz2+2*kz3+kz4)*dt/6
LET n=n+(kn1+2*kn2+2*kn3+kn4)*dt/6
END SUB
SUB graph3D
! ²óž Àû²óÃæ¿´ÅÀ center ¤ò ¸¶ÅÀ¤Ø°ÜÆ°¤·¡¢Ëô¡¢¸µ¤ØÌ᤹¹ÔÎó¡£
!(x,y,z,1)| 1, 0, 0,
0 |
!
| 0, 1, 0,
0 |
!
| 0, 0, 1,
0 |
! |-zox*Sx,-zoy*Sy,-zoz*Sz, 1 |
LET shxyzM(4,1)=-zox*Sx
LET shxyzM(4,2)=-zoy*Sy
LET shxyzM(4,3)=-zoz*Sz
!
!(x,y,z,1)| 1, 0, 0,
0 |
!
| 0, 1, 0,
0 |
!
| 0, 0, 1,
0 |
! | zox*Sx, zoy*Sy, zoz*Sz, 1 |
LET shxyzP(4,1)=zox*Sx
LET shxyzP(4,2)=zoy*Sy
LET shxyzP(4,3)=zoz*Sz
!
LET az=SS
CALL rot_panel
!---3D ¶ÊÀþ¡¢£±²óÌܤǡ¢£³£Ä¸¶²è µÏ¿¤ò»£¤ë¡£
LET ci=0
FOR t=0 TO t99 STEP dt
LET copy(ci,1)=x
LET copy(ci,2)=y
LET copy(ci,3)=z
! PRINT x;y;z;n !¡¡¥Ç¡¼¥¿¡¼¤òÊݸ¤·¤¿¤¤»þ¡£
CALL line3D(x,y,z)
CALL RungeKutta
LET ci=ci+1
NEXT t
!----
MOUSE POLL m_x,m_y,mlb,mrb
LET mxbak=m_x
LET mybak=m_y
DO
IF mlb=0 THEN LET az=MOD(az+ST,360) !¡¡£ú¼´¤Ç¡¢£±¥¹¥Æ¥Ã¥×²ó¤¹¡£
SET DRAW mode hidden
CALL rot_panel
!---3D ¶ÊÀþ¡¢£²²óÌܰʹߤϡ¢µÏ¿¤ÎºÆÀ¸¤Ç¡¢¹â®ÉÁ²è¡£
FOR ci=0 TO ci-1
CALL line3D( copy(ci,1),copy(ci,2),copy(ci,3) )
NEXT ci
SET DRAW mode explicit
!----
MOUSE POLL m_x,m_y,mlb,mrb
IF mlb=1 THEN
LET ax=ax -(m_y-mybak)!/2 !¡¡ÊÑ°ÜÊý¸þ¤Ï¡¢+90ÅÙ ²ó¤¹¡£
LET ay=ay +(m_x-mxbak)!/2
END IF
LET mxbak=m_x
LET mybak=m_y
! WAIT DELAY 0.05
LOOP UNTIL mrb=1
END SUB
SUB rot_panel
LET ar0=SQR(ax^2+ay^2) !¡¡Àû²ó³ÑÅÙ
IF ar0<>0 THEN LET DIRar0=ANGLE(ax,ay) !¡¡Àû²ó¼´¤ÎÊý¸þ
IF 180< ar0 THEN
LET ax=(ar0-360)*COS(DIRar0)
LET ay=(ar0-360)*SIN(DIRar0)
END IF
! £ø£ùÊ¿Ì̾塢£°ÅÙÊý¸þ(£ø¼´)¤ò¡¢¼´¤È¤·¤ÆÀû²ó¤¹¤ë¹ÔÎó rotx
!(x,y,z,1)|
1, 0, 0,
0 |
! | 0, cos(ar0), sin(ar0), 0 |
! | 0,-sin(ar0), cos(ar0), 0 |
! |
0, 0, 0,
1 |
LET rotx(2,2)=COS(ar0)
LET rotx(3,2)=-SIN(ar0)
LET rotx(2,3)=SIN(ar0)
LET rotx(3,3)=COS(ar0)
!
MAT P3D= shxyzM*ROTATE(az-DIRar0)*rotx*ROTATE(DIRar0)*shxyzP !ÊÑ·Á»Ø¼¨MAT
!----
CLEAR
PLOT TEXT,AT xm-hw*.9,ym+hw*.90 :t2$
PLOT TEXT,AT xm-hw*.9,ym+hw*.83 :t$
PLOT TEXT,AT xm+hw*.1,ym+hw*.83,USING"Ax=#### Ay=#### Az=####":ax,ay,az
PLOT TEXT,AT xm-hw*.9,ym-hw*.92 :t5$
PLOT TEXT,AT xm-hw*.9,ym-hw*.99 :t4$& "¡¡¡¡"& t3$ !¡¡PEN-off
!---
IF ar0< 90 THEN SET AREA COLOR "cyan" ELSE SET AREA COLOR "black"
DRAW disk WITH SCALE(15)*P3D ! ¸¶ÅÀ¶á˵¡¢Î¢É½ ¤Î¥Þ¡¼¥«¡¼£±
DRAW disk WITH SCALE(5)*SHIFT(zox*Sx,zoy*Sy)*P3D ! ¥Þ¡¼¥«¡¼£²
CALL axes3D( zox,zoy,0, zox,zoy,zoz, "center" ) ! ¥Þ¡¼¥«¡¼£³
!---ºÂɸ¼´
CALL axes3D( LH(1),0,0, LH(2),0,0, STR$(LH(2))& "( X)" )
CALL axes3D( 0,LH(3),0, 0,LH(4),0, STR$(LH(4))& "( Y)" )
CALL axes3D( 0,0,LH(5), 0,0,LH(6), STR$(LH(6))& "( Z)" )
END SUB
SUB axes3D(x1,y1,z1, x2,y2,z2, a$ )
CALL line3D(x1,y1,z1)
CALL line3D(x2,y2,z2)
PLOT TEXT,AT pV(1),pV(2) :a$ !¡¡PEN-off
END SUB
SUB line3D(x,y,z)
LET pV(1)=x*Sx !ÉÁ²èÌÜÀ¹¤Ï¡¢Á´Êý¸þÅù¤·¤¯¤Ê¤¤¤È¡¢²óž¤Ç¡¢·Á¤¬ÊݤƤʤ¤¡£
LET pV(2)=y*Sy !¥¹¥±¡¼¥ë Sx,Sy,Sz ¤Î°ã¤¤¤Ï¡¢ÆþÎϤÎÇÜΨ¤È¤·¤Æ¡¢¹Ô¤Ê¤¦¡£
LET pV(3)=z*Sz !ÆþÎÏ z ºÂɸ¤Ï ½ÐÎÏ x,y ¤ËÈ¿±Ç¡£½ÐÎÏ£ú¤Ï ÉÁ²èÉԲġ£
LET pV(4)=1 ! shxyzM ¡ÄshxyzP ¤ÇɬÍס£
MAT pV=pV*P3D
PLOT LINES: pV(1),pV(2); !¡¡PEN-on
END SUB
FOR u= left TO right STEP (right-left)/px
FOR v = bottom TO top STEP (top-bottom)/py
LET Lambda=COMPLEX(u,v)
LET z=0.5 ! ½é´üÃÍ
FOR n = 1 TO 250
IF ABS(i*z)< 710 THEN LET z=lambda*sin(z) ELSE EXIT FOR !·å¤¢¤Õ¤ìËÉ»ß
NEXT n
IF 250< n THEN PLOT POINTS: u,v
NEXT v
NEXT u
DECLARE EXTERNAL FUNCTION Ex2STR$ ! ʬ¿ô¤ò¾®¿ô,½Û´Ä¾®¿ô¤Îʸ»úÎó¤ËÊÑ´¹¤¹¤ë´Ø¿ô
DO
READ IF MISSING THEN EXIT DO : x$
PRINT x$ ; " ÆþÎÏ¿ôÃÍ"
CALL fraction(x$,a,b) ! À°¿ô,͸¾®¿ô,½Û´Ä¾®¿ô,ʬ¿ô¤Îʸ»úÎó(x$)¤ò´ûÌóʬ¿ô(a/b)¤ËÊÑ´¹
IF a>=0 THEN LET m$=" " ELSE LET m$=""
IF b=1 THEN LET f$=STR$(a) ELSE LET f$=STR$(a)&"/"&STR$(b)
PRINT m$&f$ ; " ʬ¿ôɽ¼¨"
PRINT a/b ; " ¾®¿ô15·åɽ¼¨"
PRINT m$&Ex2STR$(a,b) ; " ¾®¿ô¿¿ÃÍ[½Û´ÄÀá]ɽ¼¨" ! ʬ¿ô(a/b)¤ò¾®¿ô,½Û´Ä¾®¿ô¤Îʸ»úÎó¤ËÊÑ´¹
PRINT
LOOP
DATA "-18" , "47." , "-12.34" , "-.67" , "+972.[51]" , "-73.482[3058]"
DATA "0.000[217]" , "+6.0054[83]" , ".031[040]" , "-78/13" , "0/26" , "740.52/29.84"
DATA "634517/3637" , "24/56" , "-5/12" , "91/35" , "886240513930735/10485760"
END
EXTERNAL SUB fraction(x$,numer,denom) ! x$¤òʬ¿ônumer/denom¤ËÊÑ´¹
LET dec$=LTRIM$(RTRIM$(x$))
IF dec$(1:1)="-" THEN LET s=-1 ELSE LET s=1
IF dec$(1:1)="+" OR dec$(1:1)="-" THEN LET dec$=dec$(2:LEN(dec$))
LET sp=POS(dec$,"/")
IF sp>1 THEN ! ʬ¿ô
LET numer=VAL(dec$(1:sp-1))
LET denom=VAL(dec$(sp+1:LEN(dec$)))
CALL reduce(numer,denom) ! Ìóʬ
LET numer=s*numer
EXIT SUB
END IF
LET dp=POS(dec$,".")
IF dp=0 OR dp=LEN(dec$) THEN ! À°¿ô
LET numer=s*VAL(dec$)
LET denom=1
EXIT SUB
END IF
IF dp=1 THEN LET intp=0 ELSE LET intp=VAL(dec$(1:dp-1)) ! À°¿ôÉô
LET rp=POS(dec$,"[")
IF rp=0 THEN ! ͸¾®¿ô
LET dl=LEN(dec$)-dp
LET denom=10^dl
LET numer=intp*denom+VAL(dec$(dp+1:LEN(dec$)))
CALL reduce(numer,denom)
LET numer=s*numer
EXIT SUB
END IF
IF rp=dp+1 THEN
LET dconst=0 ! Îã"37.[61]"
LET dconst_denom=1
LET dl=0
ELSE
LET dconst=VAL(dec$(dp+1:rp-1)) ! ¾®¿ôÄê¿ôÉô
LET dl=rp-dp-1 ! ¾®¿ôÄê¿ôÉô·å¿ô
LET dconst_denom=10^dl
CALL reduce(dconst,dconst_denom)
END IF
LET rl=LEN(dec$)-rp-1 ! ½Û´ÄÀá·å¿ô
LET recur=VAL(dec$(rp+1:LEN(dec$)-1)) ! ½Û´ÄÀá
LET recur_denom=10^(LEN(dec$)-dp-2)*(1-1/10^rl)
CALL reduce(recur,recur_denom)
!PRINT intp;dconst;dconst_denom;intp+dconst/dconst_denom
!PRINT recur;recur_denom;recur/recur_denom
!! intp/1 + dconst/dconst_denom + recur/recur_denom
LET numer=intp*dconst_denom+dconst
CALL reduce(numer,dconst_denom)
LET numer=numer*recur_denom+recur*dconst_denom
LET denom=dconst_denom*recur_denom
CALL reduce(numer,denom)
LET numer=s*numer
END SUB
EXTERNAL FUNCTION Ex2STR$(numer,denom) !ʬ¿ô¤ò¾®¿ô,½Û´Ä¾®¿ô¤Îʸ»úÎó¤ËÊÑ´¹
!¡ÖNo.422 ½Û´Ä¾®¿ô¤Î·×»»(»³ÃæϵÁ»á)¡×FUNCTION ExSTR$(x) »²¾È
IF SGN(numer/denom)=-1 THEN LET u$="-" ELSE LET u$=""
LET numer=ABS(numer)
LET denom=ABS(denom)
CALL reduce(numer,denom) ! Ìóʬ
!À°¿ôÉô
IF denom=1 THEN
LET Ex2STR$=u$&STR$(numer)
EXIT FUNCTION
END IF
DIM s(denom-1) ! ¾ê;¤ò³ÊǼ¤¹¤ëÇÛÎó
LET aa=INT(numer/denom) !¾®¿ôÉô¤òºï½ü¤¹¤ë
IF aa=0 THEN LET b$="." ELSE LET b$=STR$(aa)&"."
!¾®¿ôÉô
LET p=POS(b$,".")
LET numer=MOD(numer,denom) ! ¾ê;(¾¦=aa)
LET k=1 !¾®¿ô·å
DO UNTIL numer=0
FOR i=1 TO k-1 !½Û´Ä¤·¤¿¤«³Îǧ¤¹¤ë
IF s(i)=numer THEN
LET b$(i+p:i+p)="["&b$(i+p:i+p) !³«»Ïµ¹æ¤òÁÞÆþ
LET b$=b$&"]" !½ªÎ»µ¹æ
EXIT DO
END IF
NEXT i
LET s(k)=numer
LET b$=b$&STR$(INT(10*numer/denom))
LET numer=MOD(10*numer,denom)
LET k=k+1
IF k>denom THEN ! ÇÛÎós¤Îź»ú¥ª¡¼¥Ð¡¼¤ò²óÈò¤¹¤ë
PRINT "ÊÑ´¹¤òÂǤÁÀÚ¤ê¤Þ¤·¤¿¡£"
EXIT DO
END IF
LOOP
LET Ex2STR$=u$&b$
END FUNCTION
EXTERNAL SUB reduce(p,q) ! Ìóʬ
!½½¿ÊBASICźÉÕ "\BASICw32\Math\GCDLOOP.BAS" »²¾È
REM ¸ß½üË¡¤Ë¤è¤ê¡¤ÆþÎϤµ¤ì¤¿2¿ô¤ÎºÇÂç¸øÌó¿ô¤òµá¤á¤ë ¢ª ¤½¤Î¸å,Ìóʬ
LET a=p
LET b=q
DO
LET r=MOD(a,b)
IF r=0 THEN EXIT DO
LET a=b
LET b=r
LOOP
LET p=p/b
LET q=q/b
END SUB
¤´»²¹Í¡¢Â¾¤Î´Ø¿ô¤Ê¤É¤Ï¡¢Á´¤¯°ÂÄê¤Ç¤¹¡£(sinh,cosh ¤Ï¡¢exp()¤ÈƱ¾É¾õ¡Ë
DO
WHEN EXCEPTION IN
LET w=LOG(-12345) !100000^12345 !1/0 ! EXP(12345)
USE
END WHEN
PRINT 12345
LOOP
OPTION ARITHMETIC NATIVE
OPTION ANGLE DEGREES
LET theta0=-125
LET z0=10
REM z¼´¤Î¤Þ¤ï¤ê¤Ëtheta0Åٲ󞤷¤¿sphre¤ò¡¤
REM ÅÀ(0,0,z0)¤«¤é¸«¤¿¤è¤¦¤ËÉÁ¤¯¡£
DIM p(4,4) ! ÅÀ 0,0,z0¤òÃæ¿´¤È¤¹¤ë¼Í±Æ
MAT p=IDN
LET p(3,4)=-1/z0
DIM rotx(4,4) ! x¼´¤Î¤Þ¤ï¤ê¤Î-90¡ë²óž
MAT rotx=IDN
LET rotx(2,2)=COS(-90)
LET rotx(2,3)=SIN(-90)
LET rotx(3,2)=-SIN(-90)
LET rotx(3,3)=COS(-90)
ASK PIXEL SIZE (0,1;1,0) a,b
DIM sp(a,b)
SET COLOR mode "NATIVE"
SET WINDOW -2, 2, -2, 2
DRAW sphere0 WITH ROTATE(theta0) * rotx
ASK PIXEL ARRAY (-2,2) sp
FOR t = 0 TO 360*3 STEP 15 ! µåÂΤò3²ó¥Ð¥¦¥ó¥É¤µ¤»¤ë
SET DRAW mode hidden
CLEAR
DRAW sphere WITH SHIFT(0,SIN(t))
SET DRAW mode explicit
NEXT t
PICTURE sphere
MAT PLOT CELLS ,IN -2,2; 2,-2: sp
END PICTURE
DIM sz(4,4),ry(4,4)
MAT READ sz
DATA 1,0,0,0
DATA 0,1,0,0
DATA 0,0,1,0
DATA 0,0,1,1
MAT READ ry
DATA 0, 0,-1, 0
DATA 0, 1, 0, 0
DATA 1, 0, 0, 0
DATA 0, 0, 0, 1
! µåÌ̤òÉÁ¤¯
SET AREA STYLE "SOLID"
FOR t=0 TO 180
FOR p=0 TO 359
LET ry(1,3)=-SIN(t)
LET ry(3,1)=SIN(t)
LET ry(1,1)=COS(t)
LET ry(3,3)=COS(t)
DRAW Trapezoid(t) WITH sz*ry*ROTATE(p)
NEXT p
NEXT t
PICTURE Trapezoid(t) ! t¤Ïŷĺ³Ñ
DIM N(3)
CALL makeNormal(N)
IF N(3)>0 THEN ! ³°Â¦¤¬¼êÁ°¤Ê¤éÌ̤òÉÁ¤¯
CALL setBrightness(N)
PLOT AREA: -PI/360,
-SIN(t-0.5)*PI/360; PI/360,-SIN(t+0.5)*PI/360;
PI/360,SIN(t+0.5)*PI/360; -PI/360,SIN(t-0.5)*PI/360
END IF
END PICTURE
END PICTURE
! ÊÑ´¹¤µ¤ì¤¿ºÂɸ·Ï¤Ë¤ª¤±¤ëË¡Àþ¥Ù¥¯¥È¥ë¤òµá¤á¤ë
EXTERNAL SUB makeNormal(N())
OPTION ARITHMETIC NATIVE
DIM m(4,4),A(4),B(4),C(4)
MAT m=TRANSFORM
MAT READ A
DATA 0,0,0,1
MAT READ B
DATA 1,0,0,1
MAT READ C
DATA 1,1,0,1
MAT A=A*M
MAT B=B*M
MAT C=C*M
MAT A=(1/A(4))*A
MAT B=(1/B(4))*B
MAT C=(1/C(4))*C
MAT REDIM A(3)
MAT REDIM B(3)
MAT REDIM C(3)
MAT A=B-A
MAT B=C-B
MAT N=CROSS(A,B)
END SUB
EXTERNAL SUB setBrightness(N())
OPTION ARITHMETIC NATIVE
DIM A(3)
MAT READ A ! ¸÷¸»¤Î¸þ¤
DATA -4,5,3
LET s=DOT(A,N)/(SQR(DOT(A,A))*SQR(DOT(N,N)))
LET s=(0.8*s+1)/2
SET AREA COLOR COLORINDEX(s,s,s)
END SUB
!¥«¥é¡¼¡¦¥Ü¡¼¥ë
!-------------------------------
OPTION ARITHMETIC NATIVE
OPTION ANGLE DEGREES
DIM rotx(4,4)
MAT rotx=IDN
SET WINDOW -10,10,-10,10
! £ø£ùÊ¿Ì̾å¤ÎÉÁÅÀ¤ò¡¢£ø¼´¤Ç²óž¤¹¤ë¹ÔÎó rotx
LET ar0=35
!(x,y,z,1)| 1, 0, 0, 0 |
! | 0, cos(ar0), sin(ar0), 0 |
! | 0,-sin(ar0), cos(ar0), 0 |
! |
0, 0, 0,
1 |
LET rotx(2,2)=COS(ar0)
LET rotx(3,2)=-SIN(ar0)
LET rotx(2,3)=SIN(ar0)
LET rotx(3,3)=COS(ar0)
LET r=5 !¡¡È¾·Â£µ£í¤Î¥«¥é¡¼¡¦¥Ü¡¼¥ë
LET t0=TIME
DO
LET t=TIME-t0
SET DRAW mode hidden
CLEAR
LET y=5-4.9*t^2 !¡¡ÄºÅÀ¤¬£µ£í¤ÎÊüʪÀþ
DRAW ball WITH SHIFT(0,y)
SET DRAW mode explicit
IF y< -4 THEN LET t0=t0+2*SQR((5+4)/4.9) !( 5m ¢ª -4m )»þ´Ö¤Î£²ÇܤÇÊ¿¹Ô°ÜÆ°¡£
LOOP
PICTURE ball
FOR i=-r*0.9 TO r*0.9 STEP r*0.1
SET AREA COLOR MOD(i-0.6, 0.2*r)*5
DRAW disk WITH SCALE( SQR(r^2-i^2) )*rotx*SHIFT(0, SIN(ar0)*i)
NEXT i
END PICTURE
SUB SetWindowPos( handle, C2, x0,y0,xw,yw, nFLG ) !¡¡nFLG, 0=x0y0xwyw 1=x0y0 2=xwyw
ASSIGN "user32.dll","SetWindowPos"
END SUB
!----------------------------------------------------------
SET BITMAP SIZE 501,501
LET V=5 ! ɽ¼¨Îó¿ô 3~5
SET WINDOW 0, V, 27,-6
SET AREA COLOR 5
DIM p$(5*V),wild$(5*V),names$(200)
DATA TEXTFILE\, TUTORIAL\, USERLIB\, COMM\
DATA COMPLEX\, FRACTAL\, FUNCTION\, GUIDE\
DATA LIBRARY\, MATH\, MICROSFT\, "Q&A\"
DATA SAMPLE\, STATEMEN\, ".\", "C:\My Documents\*.txt"
FOR f=1 TO 25
READ IF MISSING THEN EXIT FOR: w$
FILE splitname(w$) p$(f), name$, ext$ !¡¡ext$¤Ï¸ìƬ¤Ë"."´Þ¤à¡£
IF ext$="" THEN LET wild$(f)="*.*" ELSE LET wild$(f)=name$& ext$
NEXT f
SUB basfiles
LET m=w
CLEAR
PLOT AREA:0,-1;V,-1;V,0;0,0
SET TEXT BACKGROUND "TRANSPARENT" ! background none
PLOT TEXT,AT V*.17,0 :"¥³¥³¤òº¸¥¯¥ê¥Ã¥¯¤¹¤ë¤È½çÁ÷¤ê¡£¡¡±¦¥¯¥ê¥Ã¥¯¤Ç¡¢½ªÎ»¡£"
FOR i=0 TO 4
FOR j=1 TO V
LET w=i*V+j
IF w=m THEN PLOT AREA:j-1,i-5;j,i-5;j,i-6;j-1,i-6
IF wild$(w)="*.*" THEN LET w$=p$(w) ELSE LET w$=p$(w)& wild$(w)
PLOT TEXT,AT j-1+0.03,i-5 :w$ !p$(w)& wild$(w)
NEXT j
NEXT i
IF m>0 THEN LET n=files(p$(m)& wild$(m))
IF n>0 THEN file list p$(m)& wild$(m), names$
SET TEXT BACKGROUND "OPAQUE" ! background color 0
FOR w=1 TO n
PLOT TEXT,AT IP((w-1)/27)+0.03, MOD((w-1),27)+1 :"|"& names$(w)
NEXT w
LET bak=0
END SUB
SUB sampdisp
LET x=IP((bak-1)/27)
LET y=MOD((bak-1),27)
SET LINE COLOR 0
PLOT LINES:x,y; x+1-0.03,y; x+1-0.03,y+1; x,y+1; x,y
LET x=IP((b-1)/27)
LET y=MOD((b-1),27)
SET LINE COLOR 2
PLOT LINES:x,y; x+1-0.03,y; x+1-0.03,y+1; x,y+1; x,y
PRINT
PRINT "!*******************************"
PRINT "!"& p$(m)& names$(b)
PRINT "!*******************************"
WHEN EXCEPTION IN
OPEN #1: NAME p$(m)& names$(b),ACCESS INPUT
FOR L=1 TO 500 ! ºÇÂçɽ¼¨¹Ô¿ô
LINE INPUT #1,IF MISSING THEN EXIT FOR :w$
FOR i=1 TO LEN(w$)
IF
w$(i:i)< " " AND w$(i:i)<>CHR$(9) THEN CAUSE EXCEPTION 1
NEXT i
PRINT w$
NEXT L
USE
PRINT "¡ö¡ö¡ö¡ö¡ö¡ö¡ö ¥Æ¥¥¹¥È¤Ç¤Ï¤Ê¤¤¡¢É½¼¨¤ÎÃæ»ß¡£"
END WHEN
CLOSE #1
LET bak=b
END SUB
!¥ï¥¤¥ä¡¼¥Õ¥ì¡¼¥à¤Ç¶ÊÌ̤òÉÁ¤¯¡¡SAMPLE\3DPLOT.BAS¤ò²þ½¤¡£
SUB rotx(x,y,z,a)
LET y0=y*cos(a)-z*sin(a)
LET z0=y*sin(a)+z*cos(a)
LET y=y0
LET z=z0
END SUB
SUB roty(x,y,z,a)
LET x0=x*cos(a)+z*sin(a)
LET z0=-x*sin(a)+z*cos(a)
LET x=x0
LET z=z0
END SUB
SUB rotz(x,y,z,a)
LET x0=x*cos(a)-y*sin(a)
LET y0=x*sin(a)+y*cos(a)
LET x=x0
LET y=y0
END SUB
SUB convert(x,y,z)
CALL rotz(x,y,z,RAD(-30))
CALL rotx(x,y,z,RAD(-70))
END SUB
SUB plotTo(x,y,z)
LET x1=x
LET y1=y
LET z1=z
CALL convert(x1,y1,z1)
PLOT LINES:x1,y1;
END SUB
SUB PenUp
PLOT LINES
END SUB
SUB PlotText(x,y,z,s$)
CALL convert(x,y,z)
PLOT TEXT ,AT x,y: s$
END SUB
!ÇÞÂÎÊÑ¿ôɽ¼¨
DEF fx(u,v)=COS(u)*SIN(v) !µå¡¡u=[0,2*PI],v=[0,PI]¡¡¢¨µåºÂɸ(r,¦È,¦Õ)
DEF fy(u,v)=SIN(u)*SIN(v)
DEF fz(u,v)=COS(v)
SET WINDOW -2,2,-2,2
FOR f=0 TO 360 !¥Õ¥ì¡¼¥à¡¦¥¢¥Ë¥á¡¼¥·¥ç¥ó
SET DRAW mode hidden !¤Á¤é¤Ä¤Ëɻߡʳ«»Ï¡Ë
CLEAR
! ¼´¤òÉÁ¤¯
CALL PlotTo(0,0,0)
CALL PlotTo(2,0,0)
CALL PlotTo(0,0,0)
CALL PlotTo(0,2,0)
CALL PlotTo(0,0,0)
CALL PlotTo(0,0,2)
CALL PenUp
CALL PlotText(2,0,0,"x")
CALL PlotText(0,2,0,"y")
CALL PlotText(0,0,2,"z")
! ¶ÊÌ̤òÉÁ¤¯
FOR u=0 TO 360 STEP 15
FOR v=0 TO 180 STEP 15
LET x=fx(RAD(u),RAD(v))
LET y=fy(RAD(u),RAD(v))
LET z=fz(RAD(u),RAD(v))
CALL rotx(x,y,z,RAD(f))
CALL PlotTo(x,y,z)
NEXT v
CALL PenUp
NEXT u
FOR v=0 TO 180 STEP 30
FOR u=-1 TO 360 STEP 30
LET x=fx(RAD(u),RAD(v))
LET y=fy(RAD(u),RAD(v))
LET z=fz(RAD(u),RAD(v))
CALL rotx(x,y,z,RAD(f))
CALL PlotTo(x,y,z)
NEXT u
call PenUp
NEXT v
SET DRAW mode explicit !¤Á¤é¤Ä¤ËɻߡʽªÎ»¡Ë
!WAIT DELAY 0.1
NEXT f
END
!-------read binary cx bytes
SUB readCI(cx) !¡¡cx=bytes size
LET db$=""
FOR i=1 TO cx
CHARACTER INPUT #1,IF MISSING THEN EXIT SUB :w9$
LET db$=db$& w9$
NEXT i
END SUB
!-------
FUNCTION bitand8(a,b)
LET b9$="00000000"
LET b8$=right$("0000000"& BSTR$(a,2),8)
LET b7$=right$("0000000"& BSTR$(b,2),8)
FOR b9=1 TO 8
IF b8$(b9:b9)="1" AND b7$(b9:b9)="1" THEN LET b9$(b9:b9)="1"
NEXT b9
LET bitand8=BVAL(b9$,2)
END FUNCTION
FUNCTION bitor8(a,b)
LET b9$="00000000"
LET b8$=right$("0000000"& BSTR$(a,2),8)
LET b7$=right$("0000000"& BSTR$(b,2),8)
FOR b9=1 TO 8
IF b8$(b9:b9)="1" OR b7$(b9:b9)="1" THEN LET b9$(b9:b9)="1"
NEXT b9
LET bitor8=BVAL(b9$,2)
END FUNCTION
FUNCTION frac2dec$(m,n,RADIX) !10¿Êˡʬ¿ô¡Êm/n¡Ë¤ò(RADIX)¿Ê¿ô¤Ç¾®¿ôɽ¼¨¤¹¤ë¤È¤¤Îʸ»úÎó¤ËÊÑ´¹¤¹¤ë
IF SGN(m)*SGN(n)<0 THEN LET cSGN$="-" ELSE LET cSGN$="" !Éä¹æ¤òÆÀ¤ë
LET aa=ABS(m)
LET b=ABS(n)
LET t=GCD(aa,b) !ºÇÂç¸øÌó¿ô¤Çʬ»Ò¤ÈʬÊì¤òÌóʬ¤¹¤ë
LET aa=aa/t
LET b=b/t
!!!PRINT aa;b;t !debug
!À°¿ôÉô
LET a=INT(aa/b) !¾®¿ôÉô¤òºï½ü¤¹¤ë
LET b$="" !ÊÑ´¹¸å¤Î¿ô
DO WHILE a>=RADIX !a=b[k]*RADIX^k+b[k-1]*RADIX^(k-1)+ ¡Ä +b[1]*RADIX^1+b[0]*RADIX^0¤è¤ê
LET b$=STR1$(MOD(a,RADIX))&b$ !°ì¤Î°Ì¤«¤éµá¤Þ¤ë
LET a=INT(a/RADIX) !¼¡¤Î·å¤Ø ¢¨±¦¥·¥Õ¥È
LOOP
LET b$=STR1$(a)&b$
!¾®¿ôÉô
LET aa=MOD(aa,b) !À°¿ôÉô¤òºï½ü¤¹¤ë
LET k=0 !¾®¿ôÉô¤Î·å¿ô
DO UNTIL aa=0 !¾®¿ôÂ裱°Ì¤«¤é½ç¤Ë
LET k=k+1
IF k>MIN(b,Precision) THEN !½Û´Ä¾®¿ô¤Ë¤è¤ë¥ë¡¼¥×¤ò²óÈò¤¹¤ë
PRINT "ÊÑ´¹¤òÂǤÁÀÚ¤ê¤Þ¤·¤¿¡£"
EXIT DO
END IF
IF k=1 THEN !½é²ó¤Î¤ß
LET b$=b$&"." !¾®¿ôÅÀ¤ò¤Ä¤±¤ë
LET p=LEN(b$) !°ÌÃÖ¤òµÏ¿¤·¤Æ¤ª¤¯
ELSE
FOR i=1 TO k-1 !½Û´Ä¤·¤¿¤«¤É¤¦¤«³Îǧ¤¹¤ë
IF s(i)=aa THEN EXIT DO !½Û´ÄÀá¤Ê¤é¡¢½ªÎ»¡ª
NEXT i
END IF
LET s(k)=aa !¾®¿ôÂè£ë°Ì°Ê¹ß¡Ê̤Ÿ³«¤Î¾®¿ôÉô¡Ë¤Î¿ô¤òµÏ¿¤¹¤ë
LET aa=aa*RADIX !º¸¥·¥Õ¥È¤·¤Æ¡¢¾¦¤òµá¤á¤ë
LET a=INT(aa/b)
LET b$=b$&STR1$(a) !a=S[-1]*RADIX^(-1)+S[-2]*RADIX^(-2)+ ¡Ä +S[-(k-1)]*RADIX^(-(k-1))+S[-k]*RADIX^(-k)¤è¤ê
LET aa=MOD(aa,b) !¾ê;¤òµá¤á¤Æ¡¢¼¡¤Î·å¤Ø
LOOP
IF aa=0 THEN !͸¾®¿ô¡ÊÀ°¿ô¤â´Þ¤à¡Ë¤Ê¤é
LET p=k !͸¾®¿ô¤Î·å¿ô
LET k=0 !½Û´ÄÀá¤Î·å¿ô
ELSE !½Û´Ä¾®¿ô¤Ê¤é
LET b$(i+p:i+p)="["&b$(i+p:i+p) !³«»Ïµ¹æ¤òÁÞÆþ
LET b$=b$&"]" !½ªÎ»µ¹æ
LET p=i-1 !͸¾®¿ô¤Î·å¿ô
LET k=k-i !½Û´ÄÀá¤Î·å¿ô
END IF
LET frac2dec$=cSGN$&b$ !-9.9[9] ·Á¼°
END FUNCTION
!------------------------------ ¤³¤³¤Þ¤Ç¤¬¥µ¥Ö¥ë¡¼¥Á¥ó
!¡ü 0.[13](4)¤ò10¿ÊË¡¤Îʬ¿ô¤Çɽ¸½¤¹¤ë Åú¤¨ 7/15
!¢¨ÅùÈæ¿ôÎó¤ÎÏ ½é¹à 0.13(4)=1/4^1+3/4^2¡¢¸øÈæ 0.01(4)=1/4^2
! LET a = 0. + (1/4^1+3/4^2)/(1-1/4^2)
! PRINT a
PRINT ExBVAL("0.[13]",4)
!¡ü 1/7¤ò3¿ÊË¡¤Î¾®¿ô¡Ê½Û´Ä¤¹¤ë¡Ë¤Çɽ¸½¤¹¤ë Åú¤¨ 0.[010212](3)
PRINT ExBSTR$(1/7,3)
!¡ü 0.1[23] ¡à 0.[14] ¤Î·ë²Ì¤ò½Û´Ä¾®¿ô¤Çɽ¤»¡£ Åú¤¨ 0.8[714285]
!É®»»
! x=0.1[23]¤È¤¹¤ë¤È
! 100*x-x=12.3[23]-0.1[23]=12.2 ¡è99*x=122/10 ¡èx=61/495
LET t=ExVAL("0.1[23]") / ExVAL("0.[14]")
PRINT t, ExSTR$(t)
!¡ü 3/7 ¤ò¾®¿ô¤Çɽ¤·¤¿¤È¤¡¢¾®¿ôÂ裸£°£°°Ì¤Î¿ô»ú¤òµá¤á¤è¡£ Åú¤¨ 2
LET x$=ExSTR$(3/7) !0.[428571]
LET y$=x$(POS(x$,"[")+1:POS(x$,"]")-1) !½Û´ÄÀá¤òÀÚ¤ê½Ð¤¹
LET x=MOD(800,LEN(y$)) !800/6=133 ;¤ê 2
PRINT y$(x:x)
END
! GIF ¥Õ¥¡¥¤¥ë¤Î²òÀϥġ¼¥ë
!-------
OPTION CHARACTER BYTE
!
FILE GETNAME file$, "gif"
IF file$="" THEN
PRINT "ÆþÎÏ¥Õ¥¡¥¤¥ë̾¤¬¡¢¤¢¤ê¤Þ¤»¤ó¡£"
STOP
END IF
PRINT "ÆþÎÏ¥Õ¥¡¥¤¥ë¡§"& file$
!
OPEN #1: NAME file$, ACCESS INPUT
PRINT "---------"
CALL gif_head
DO
CALL blocks_main
LOOP UNTIL b1$=CHR$(BVAL("3B",16))
PRINT "GIF ½ªÃ¼¥Ö¥í¥Ã¥¯"
CALL dump(b1$,16,"block label")
PRINT "---------"
CLOSE #1
IF c_p$>"" OR p_p$="" OR im$>"" OR ap$>"" OR co$>"" OR tx$>"" THEN STOP
PRINT "½½¿ÊBASIC ½ÐÎϤΠGIF ¥Õ¥¡¥¤¥ë¤Î¤è¤¦¤Ç¤¹¡£"
!----
SUB gif_head
LET h$=""
CALL readb( h$,13 )
IF h$(1:3)="GIF" THEN PRINT "GIF ¥Ø¥Ã¥À¡¼" ELSE CALL error
LET Xsw= ORD(h$( 8: 8))*256+ORD(h$(7:7))
LET Ysw= ORD(h$(10:10))*256+ORD(h$(9:9))
LET sflg= ORD(h$(11:11)) ! ¥¹¥¯¥ê¡¼¥ó¾ðÊó¤Î¥Õ¥é¥°
LET aspect=ORD(h$(13:13))
LET b$=right$("0000000"& BSTR$(sflg,2) ,8)
LET colpix=2^(BVAL(b$(2:4),2)+1)
LET compal=2^(BVAL(b$(6:8),2)+1)
CALL dumpASC(h$(1:6),8) ! GIF¼±ÊÌʸ»ú
CALL dump(h$( 7: 8),16,"screen X_width "& STR$(Xsw))
CALL dump(h$( 9:10),16,"screen Y_width "& STR$(Ysw))
CALL dump(h$(11:11),16,"flags "& b$ )
PRINT TAB(12);b$(1:1);":common_palette on=1/off=0"
PRINT TAB(10);b$(2:4);":colors/pixel 2^(";b$(2:4);"b+1)= ";STR$(colpix)
PRINT TAB(12);b$(5:5);":sort on=1/off=0 ÉÑÅ٤什ç( outer use)"
PRINT TAB(10);b$(6:8);":common_palette colors 2^(";b$(6:8);"b+1)= ";STR$(compal)
CALL dump(h$(12:12),16,"back_ground color_code")
IF aspect=0 THEN LET b$=".." ELSE LET b$=STR$(aspect)
CALL dump(h$(13:13),16,"¥¢¥¹¥Ú¥¯¥ÈÈæ pixel H:V=("& b$& "+15):64 =1:1( 00)" )
CALL palette("common_¥Ñ¥ì¥Ã¥È", c_p$, sflg)
END SUB
!----
SUB blocks_main
LET b1$=""
CALL readb( b1$, 1)
IF b1$=CHR$(BVAL("21",16)) THEN !Äɲåǡ¼¥¿¡¦¥Ö¥í¥Ã¥¯
CALL option_block
ELSEIF b1$=CHR$(BVAL("2C",16)) THEN !²èÁü¥Ö¥í¥Ã¥¯
CALL picture_block
ELSEIF b1$=CHR$(BVAL("3B",16)) THEN !GIF ½ªÃ¼¥Ö¥í¥Ã¥¯
ELSE
CALL error
END IF
END SUB
SUB blocksNP1(d$)
CALL
readb(d$,1)
! w9$= readb_last_byte ! =block Size
CALL dump(w9$,16,"block size")
IF w9$=CHR$(0) THEN EXIT SUB ! block End
CALL readb(d$,ORD(w9$)) ! block data
END SUB
SUB blocks(d$)
DO
CALL
readb(d$,1)
! w9$= readb_last_byte ! =block Size
CALL dump(w9$,16,"block size")
IF w9$=CHR$(0) THEN EXIT SUB ! block End
LET s=LEN(d$)
CALL readb(d$,ORD(w9$)) ! block data
CALL dump(d$(s+1:LEN(d$)),16,"")
LOOP
END SUB
SUB blocksASC(d$,n) !n=¥Ö¥í¥Ã¥¯¿ô¤Î¾å¸Â
FOR n=1 TO n
CALL
readb(d$,1)
! w9$= readb_last_byte ! =block Size
CALL dump(w9$,16,"block size")
IF w9$=CHR$(0) THEN EXIT SUB ! block End
LET s=LEN(d$)
CALL readb(d$,ORD(w9$)) ! block data
CALL dumpASC(d$(s+1:LEN(d$)),8)
NEXT n
END SUB
SUB readb(d$,cx) !cx=bytes size
FOR i=1 TO cx
CHARACTER INPUT #1,IF MISSING THEN EXIT FOR :w9$
LET d$=d$& w9$
NEXT i
IF i<=cx THEN CALL error
END SUB
SUB picture_block
PRINT "²èÁü¥Ö¥í¥Ã¥¯"
LET pi$=b1$
CALL readb( pi$,9) ! w9$= readb_last_byte
CALL dump(pi$(1:1),16,"block label")
LET Xp0=ORD(pi$(3:3))*256+ORD(pi$(2:2))
LET Yp0=ORD(pi$(5:5))*256+ORD(pi$(4:4))
LET Xpw=ORD(pi$(7:7))*256+ORD(pi$(6:6))
LET Ypw=ORD(pi$(9:9))*256+ORD(pi$(8:8))
CALL dump(pi$(2:3),16,"picture.X0_position left "& STR$(Xp0))
CALL dump(pi$(4:5),16,"picture.Y0_position top "& STR$(Yp0))
CALL dump(pi$(6:7),16,"picture.X_width "& STR$(Xpw))
CALL dump(pi$(8:9),16,"picture.Y_width "& STR$(Ypw))
LET pflg=ORD(pi$(10:10)) ! ²èÁü¾ðÊó¤Î¥Õ¥é¥°
LET b$=right$("0000000"& BSTR$(pflg,2),8)
LET pripal=2^(BVAL(b$(6:8),2)+1)
CALL dump(pi$(10:10),16,"flags "& b$ )
PRINT TAB(12);b$(1:1);":private_palette on=1/off=0"
PRINT TAB(12);b$(2:2);":interrace on=1/off=0, 1~step8 5~step8 3~step4 2~step2"
PRINT TAB(12);b$(3:3);":sort on=1/off=0 ÉÑÅ٤什ç( outer use)"
PRINT TAB(11);b$(4:5);":blank"
PRINT TAB(10);b$(6:8);":private_palette colors 2^(";b$(6:8);"b+1)= ";STR$(pripal)
CALL palette("private_¥Ñ¥ì¥Ã¥È", p_p$, pflg)
!---
PRINT "²èÁü¥Ç¡¼¥¿"
LET pda$=""
CALL readb( pda$,1)
CALL dump(pda$,16,"ºÇ¾®¥Ç¡¼¥¿¡¦¥Ó¥Ã¥ÈĹ")
!--- LZW ¥Ç¡¼¥¿¡Êsize:data, size:data, ¡Ä 0 ¡Ë
CALL blocks(pda$)
END SUB
SUB palette(n$, p$, pf)
PRINT n$;
LET p$=""
IF INT(pf/128)>0 THEN ! pf AND 0x80
PRINT
CALL readb(p$, 3*2^(MOD(pf,8)+1)) ! pf AND 0x07
CALL dump(p$,3,"R G B")
ELSE
PRINT "¤Ï¡¢Í¤ê¤Þ¤»¤ó¡£"
END IF
END SUB
SUB error
beep
PRINT "File Error Stop"
STOP
END SUB
!-------
FUNCTION bitand8(a,b)
LET b9$="00000000"
LET b8$=right$("0000000"& BSTR$(a,2),8)
LET b7$=right$("0000000"& BSTR$(b,2),8)
FOR b9=1 TO 8
IF b8$(b9:b9)="1" AND b7$(b9:b9)="1" THEN LET b9$(b9:b9)="1"
NEXT b9
LET bitand8=BVAL(b9$,2)
END FUNCTION
FUNCTION bitor8(a,b)
LET b9$="00000000"
LET b8$=right$("0000000"& BSTR$(a,2),8)
LET b7$=right$("0000000"& BSTR$(b,2),8)
FOR b9=1 TO 8
IF b8$(b9:b9)="1" OR b7$(b9:b9)="1" THEN LET b9$(b9:b9)="1"
NEXT b9
LET bitor8=BVAL(b9$,2)
END FUNCTION
!-------
SUB dump(d$,m,t$)
FOR j=1 TO LEN(d$) STEP m
LET ww$=right$("000"& BSTR$(adr,16),4)& " "
FOR i=j TO MIN(j+m-1, LEN(d$))
LET ww$=ww$& " "& right$("0"& BSTR$( ORD(d$(i:i)),16),2)
LET adr=adr+1
NEXT i
IF t$>"" AND j<=m THEN LET ww$=ww$& " ;"& t$
PRINT ww$ !¹Ôñ°Ì¡¢¥Æ¥¥¹¥È²èÌ̤Υԥ«¤Ä¤¸º¾¯¡¢¹â®¡£
NEXT j
END SUB
SUB dumpASC(d$,m)
FOR j=1 TO LEN(d$) STEP m
LET ww$=right$("000"& BSTR$(adr,16),4)& " "
FOR i=j TO MIN(j+m-1, LEN(d$))
LET ww$=ww$& " "& right$("0"& BSTR$( ORD(d$(i:i)),16),2)
LET adr=adr+1
NEXT i
LET ww$=ww$& REPEAT$(" ",3*m+6-LEN(ww$))& ";"""
FOR i=j TO MIN(j+m-1, LEN(d$))
IF " "<=d$(i:i) THEN LET ww$=ww$& d$(i:i) ELSE LET ww$=ww$& "."
NEXT i
LET ww$=ww$& """"
PRINT ww$
NEXT j
END SUB
!ÏÀÍý¼°¤Î·×»»
DEF AND3(a,b,c)=AND(AND(a,b),c) !£³ÊÑ¿ô°Ê¾å¤Î¾ì¹ç
DEF AND4(a,b,c,d)=AND(AND(a,b),AND(c,d))
DEF OR3(a,b,c)=OR(OR(a,b),c)
DEF OR4(a,b,c,d)=OR(OR(a,b),OR(c,d))
LET C1=NT(0) !1¡¡¢¨¡Ý£±¤Î¥Ó¥Ã¥È¥Ñ¥¿¡¼¥ó
!------------------------------ ¤³¤³¤Þ¤Ç¤¬¥Þ¥¯¥í¤ÎÄêµÁ
LET N=3 !ÊÑ¿ô¤Î¿ô¡¡¢¨£±¡Á£µ
LET A=BOOL(N,1) !£Î¸Ä¤ÎÊÑ¿ô¤Î£±ÈÖÌÜ
LET B=BOOL(N,2)
LET C=BOOL(N,3)
!LET D=BOOL(N,4)
!LET E=BOOL(N,5)
LET nA=NT(A) !A' Ê丵
LET nB=NT(B)
LET nC=NT(C)
!LET nD=NT(D)
!LET nE=NT(E)
!¡üÏÀÍý¼°¤Î¿¿ÍýÃÍɽ¤ò¤Ä¤¯¤ë
PRINT BitPTN$(N, A); ":A"
PRINT BitPTN$(N, B); ":B"
PRINT BitPTN$(N, C); ":C"
LET f=OR3(AND3(A,B,C), AND3(A,nB,C), AND3(A,B,nC))
PRINT BitPTN$(N, f); ":ABC+AB'C+ABC'"
PRINT
!¡üÏÀÍý¼°¤ò¼ç²Ãˡɸ½àŸ³«¡¢¼ç¾èˡɸ½àŸ³«¤¹¤ë
LET f=OR(A,AND(B,C))
!PRINT BitPTN$(N, f); ":A+BC"
CALL PrintPDCF(N,f)
CALL PrintPCCF(N,f)
PRINT
!¡ü¥¯¥ï¥¤¥ó¡¦¥Þ¥¯¥é¥¹¥¡¼Ë¡¡ÊQuine-McCluskey algorithm¡Ë¤Ç¼°¤ò´Êñ²½¤¹¤ë
!¥¹¥Æ¥Ã¥×£°¡¡ÏÀÍý¼°¤Î¿¿ÍýÃÍɽ¤ò¤Ä¤¯¤ë
LET f=OR4(AND3(nA,B,C),AND3(A,nB,C),AND3(A,B,nC),AND3(A,B,C))
!PRINT BitPTN$(N, f); ":A'BC+AB'C+ABC'+ABC"
!¥¹¥Æ¥Ã¥×£±¡¡ÏÀÍý¼°¤òºÇ¾®¹à¤Çµ½Ò¤¹¤ë¡Ê¼ç²Ãˡɸ½àŸ³«¡Ë
DIM Term$(2^N) !ºÇ¾®¹à¤Î¥Ó¥Ã¥È¥Ñ¥¿¡¼¥ó
LET CntOfTerm=0 !ºÇ¾®¹à¤Î¿ô
FOR i=0 TO 2^N-1 !¿¿ÍýÃÍɽ¤ò£²¿ÊË¡¤Î¿ô¤È¤ß¤Ê¤·¤Æ¾®¤µ¤¤½ç¤Ë
IF Bit(f,i)=1 THEN !ºÇ¾®¹à¤Ê¤é
LET CntOfTerm=CntOfTerm+1
LET Term$(CntOfTerm)=right$(REPEAT$("0",N-1)&BSTR$(i,2),N) !¥Ó¥Ã¥È¥Ñ¥¿¡¼¥ó¤Ï¡¢¡ÄDCBA½ç
END IF
NEXT i
!FOR i=1 TO CntOfTerm !debug
! PRINT Term$(i)
!NEXT i
IF CntOfTerm=0 THEN !¤¹¤Ù¤Æ£°¤Ê¤é¡¢½ªÎ»¡ª
PRINT "0"
STOP
ELSEIF CntOfTerm=2^N THEN !¤¹¤Ù¤Æ¤Î£±¤Ê¤é¡¢½ªÎ»¡ª
PRINT "1"
STOP
END IF
!¥¹¥Æ¥Ã¥×£²¡¡AB+AB'=A¤ò»È¤Ã¤Æ¡¢ºÇ¾®¹à¤ÎÊÑ¿ô¤ò¸º¤é¤¹
DIM wTerm$(100) !ºî¶ÈÍѤ˥³¥Ô¡¼¤¹¤ë
FOR i=1 TO CntOfTerm
LET wTerm$(i)=Term$(i)
NEXT i
LET wCntOfTerm=CntOfTerm
DIM Term9$(2^N) !¼ç¹à¤Î¥Ó¥Ã¥È¥Ñ¥¿¡¼¥ó
LET CntOfTerm9=0 !¼ç¹à¤Î¿ô
DO
DIM CHK(100) !°µ½Ì¤ÎÍ̵
MAT CHK=ZER
LET CntOfCompTRM=0 !°µ½Ì¤µ¤ì¤¿¹à¤Î¿ô
FOR i=1 TO wCntOfTerm-1 !¤¹¤Ù¤Æ¤ÎÁȹ礻¤Ç¹Íθ¤¹¤ë
FOR j=i+1 TO wCntOfTerm
LET CntOf1=0 !¡Ö£±¡×¤Î¿ô
FOR k=1 TO N !¥Ó¥Ã¥Èñ°Ì¤ÎÇÓ¾ŪÏÀÍýϤòµá¤á¤ë
LET t1$=wTerm$(i)(k:k)
LET t2$=wTerm$(j)(k:k)
IF (t1$="1" AND t2$="0") OR (t1$="0" AND t2$="1") THEN !¡Ö£±¡×¤È¤¹¤ë
LET CntOf1=CntOf1+1
LET PosOf1=k !¾Ãµî¤µ¤ì¤ëÊÑ¿ô¤Î°ÌÃÖ
ELSEIF (t1$="0" AND t2$="0") OR (t1$="1" AND t2$="1") THEN !¡Ö£°¡×¤È¤¹¤ë
!skip it
ELSEIF (t1$="-" AND t2$="-") THEN !¥Þ¥¹¥¯¡¦¥Ó¥Ã¥È¤Ê¤é
!skip it
ELSE !ÊÒÊý¤¬¥Þ¥¹¥¯¡¦¥Ó¥Ã¥È¤Ê¤é¡¢¸õÊä¤Ç¤Ï¤Ê¤¤¡ª
LET CntOf1=N
EXIT FOR
END IF
NEXT k
IF CntOf1=1 THEN !AB+AB'=A¡Ê¥Ï¥ß¥ó¥°µ÷Î¥¤¬£±¡Ë¤è¤ê¡¢¾Ãµî¤¹¤ë
LET t$=wTerm$(i) !¥Ó¥Ã¥È¥Ñ¥¿¡¼¥ó
LET t$(PosOf1:PosOf1)="-" !¤½¤ÎÊÑ¿ô¤ò¾Ãµî¤¹¤ë
LET CHK(i)=1 !°µ½Ì¤¢¤ê
LET CHK(j)=1
DIM CompTRM$(100)
FOR k=1 TO CntOfCompTRM !Ʊ¤¸¹à¤¬¤¢¤ë¤«³Îǧ¤¹¤ë
IF t$=CompTRM$(k) THEN EXIT FOR
NEXT k
IF k>CntOfCompTRM THEN !¤Ê¤±¤é¤Ð¡¢¿·µ¬¤ËÅÐÏ¿¤¹¤ë
LET CntOfCompTRM=CntOfCompTRM+1
LET CompTRM$(CntOfCompTRM)=t$
!PRINT i;j; t$ !debug
END IF
END IF
NEXT j
NEXT i
LET Cnt=0 !º£²ó°µ½Ì¤Ç¤¤Ê¤«¤Ã¤¿¹à¤Î¿ô
FOR i=1 TO wCntOfTerm !°µ½Ì¤µ¤ì¤Ê¤¤¤â¤Î¤Ï¡¢¼ç¹à¤È¤Ê¤ë
IF CHK(i)=0 THEN
LET Cnt=Cnt+1
LET CntOfTerm9=CntOfTerm9+1 !¼ç¹à¤È¤·¤ÆµÏ¿¤¹¤ë
LET Term9$(CntOfTerm9)=wTerm$(i)
END IF
NEXT i
IF Cnt=wCntOfTerm THEN EXIT DO !¤¹¤Ù¤Æ°µ½Ì¤Ç¤¤Ê¤±¤ì¤Ð¡¢½ªÎ»¡ª
FOR i=1 TO CntOfCompTRM !¼¡¤Ø
LET wTerm$(i)=CompTRM$(i) !copy it
NEXT i
LET wCntOfTerm=CntOfCompTRM
LOOP
!¥¹¥Æ¥Ã¥×£³¡¡¼ç¹àɽ¤ò»È¤Ã¤Æ¾éĹ¤Ê¼ç¹à¤òºï½ü¤¹¤ë
!¥¹¥Æ¥Ã¥×£³¡Ý£±¡¡¼ç¹àɽ¤ò¤Ä¤¯¤ë
DIM TT(CntOfTerm9,CntOfTerm) !¼ç¹àɽ¡Ê¿Þ¡Ë¡¡¢¨TT(¼ç¹à,ºÇ¾®¹à)
MAT TT=ZER
FOR i=1 TO CntOfTerm9 !ºÇ¾®¹à¤òÊñ´Þ¤¹¤ë¼ç¹à¤Ë¥Á¥§¥Ã¥¯¤òÆþ¤ì¤ë
FOR j=1 TO CntOfTerm
FOR k=1 TO N
LET t$=Term9$(i)(k:k)
IF t$<>"-" THEN !¥Þ¥¹¥¯¡¦¥Ó¥Ã¥È°Ê³°¤¬ÉÔ°ìÃפʤ顢½ªÎ»¡ª
IF t$<>Term$(j)(k:k) THEN EXIT FOR
END IF
NEXT k
IF k>N THEN LET TT(i,j)=1 !¤¹¤Ù¤Æ¤Î¥Ó¥Ã¥È¤¬°ìÃפ¹¤ì¤Ð¡¢Êñ´Þ¤¹¤ë
NEXT j
NEXT i
!MAT PRINT TT; !debug
!¥¹¥Æ¥Ã¥×£³¡Ý£²¡¡¼ç¹àɽ¤«¤éɬ¿Ü¹à¤òõ¤¹
DIM CHK2(CntOfTerm9) !ɬ¿Ü¹à¤È¤·¤Æ¥Á¥§¥Ã¥¯¤¹¤ë
MAT CHK2=ZER
MAT CHK=ZER
FOR j=1 TO CntOfTerm !¼ç¹àɽ¤«¤éɬ¿Ü¹à¤òõ¤¹
LET Cnt=0
FOR i=1 TO CntOfTerm9 !Îó¤ÇÁöºº¤·¤Æ¡¢¡Ö£±¡×¤¬£±¤Ä¤ÎÎó¤ò¸«¤Ä¤±¤ë
IF TT(i,j)=1 THEN
LET Cnt=Cnt+1
LET PosOf1=i !¹Ô°ÌÃÖ
END IF
NEXT i
IF Cnt=1 THEN !£±¤Ä¤Î¤â¤Î¤Ï¡¢É¬¿Ü¹à¤È¤¹¤ë
LET CHK2(PosOf1)=1
FOR k=1 TO CntOfTerm !ɬ¿Ü¹à¤À¤±¤ÇºÇ¾®¹à¤òÊñ´Þ¤¹¤ë¤«¡Ê¾éĹÀ¡Ë
LET CHK(k)=OR(CHK(k),TT(PosOf1,k))
NEXT k
END IF
NEXT j
!MAT PRINT CHK; !debug
!MAT PRINT CHK2;
!¥¹¥Æ¥Ã¥×£³¡Ý£³¡¡É¬¿Ü¹à¤ÈÁªÂò¹à¤ÎÁȤ߹ç¤ï¤»¤Ç²áÉÔ¤ʤ¯¹à¤òÁª¤Ö
DO
FOR j=1 TO CntOfTerm !Êñ´Þ¤µ¤ì¤Æ¤¤¤Ê¤¤²Õ½ê¤òõ¤¹
IF CHK(j)=0 THEN EXIT FOR
NEXT j
IF j>CntOfTerm THEN EXIT DO !ɬ¿Ü¹à¡ÜÁªÂò¹à¤ÇºÇ¾®¹à¤òÊñ´Þ¤¹¤ë¤Ê¤é¡¢½ªÎ»¡ª
FOR i=1 TO CntOfTerm9 !¤½¤Î²Õ½ê¤òÁªÂò¹à¤ÇËä¤á¤ë
IF TT(i,j)=1 THEN !¹Ô°ÌÃÖ
LET CHK(j)=2
LET CHK2(i)=2 !ÁªÂò¹à¤Ë²Ã¤¨¤ë
EXIT FOR
END IF
NEXT i
!MAT PRINT CHK; !debug
!MAT PRINT CHK2;
LOOP
!·ë²Ì¤òɽ¼¨¤¹¤ë
FOR i=1 TO CntOfTerm9
IF CHK2(i)>0 THEN !ɬ¿Ü¹à¤Þ¤¿¤ÏÁªÂò¹à¤Ê¤é
PRINT "+";
FOR k=0 TO N-1 !ÊÑ¿ô¤Ø
SELECT CASE Term9$(i)(N-k:N-k) !¥Ó¥Ã¥È¥Ñ¥¿¡¼¥ó¤òÆÀ¤ë¡¡¢¨¡ÄDCBA½ç
CASE "0"
PRINT CHR$(k+ORD("A"));"'"; !ÈÝÄê
CASE "1"
PRINT CHR$(k+ORD("A"));
CASE ELSE !"-"
END SELECT
NEXT k
END IF
NEXT i
PRINT
END
EXTERNAL FUNCTION BOOL(N,i) !¿¿ÍýÃÍɽ¤Ç¤ÎÊÑ¿ôA¡ÁZ¤Î¥Ó¥Ã¥È¥Ñ¥¿¡¼¥ó¡Ê2^N ·å¡Ë¤òµá¤á¤ë
LET t$=REPEAT$("1",2^(i-1))&REPEAT$("0",2^(i-1)) !11¡Ä100¡Ä0
LET BOOL=BVAL(REPEAT$(t$,2^(N-i)),2) !A,B,C,¡Ä
END FUNCTION
!½ÐÎÏ´ØÏ¢
EXTERNAL SUB PrintPDCF(N,f) !¿¿ÍýÃÍɽ¤ò¼ç²Ãˡɸ½à·Á¡ÊÁª¸Àɸ½à·Á¡Ë¤Ç½ÐÎϤ¹¤ë
FOR i=0 TO 2^N-1
IF Bit(f,i)=1 THEN !ºÇ¾®¹à
PRINT "+";
FOR x=0 TO N-1
PRINT CHR$(x+ORD("A")); !ÊÑ¿ô̾
IF Bit(i,x)=0 THEN PRINT "'"; !ÈÝÄêµ¹æ
NEXT x
END IF
NEXT i
PRINT
END SUB
EXTERNAL SUB PrintPCCF(N,f) !¿¿ÍýÃÍɽ¤ò¼ç¾èˡɸ½à·Á¡ÊÏ¢¸Àɸ½à·Á¡Ë¤Ç½ÐÎϤ¹¤ë
FOR i=0 TO 2^N-1
IF Bit(f,i)=0 THEN !ºÇÂç¹à
PRINT "(";
FOR x=0 TO N-1
PRINT "+";
PRINT CHR$(x+ORD("A")); !ÊÑ¿ô̾
IF Bit(i,x)=1 THEN PRINT "'"; !ÈÝÄêµ¹æ
NEXT x
PRINT ")";
END IF
NEXT i
PRINT
END SUB
!Êä½õ¥ë¡¼¥Á¥ó
EXTERNAL FUNCTION Bit(x,m) !m¥Ó¥Ã¥ÈÌܤòÆÀ¤ë¡¡0,1
LET Bit=MOD(INT(x/2^m),2)
END FUNCTION
EXTERNAL FUNCTION BitPTN$(N,a) !¥Ó¥Ã¥È¥Ñ¥¿¡¼¥ó¡Ê2^N ·å¡Ë¤òµá¤á¤ë
IF a>=0 THEN
LET a$=REPEAT$("0",2^N-1)&BSTR$(a,2)
ELSE
LET a$=BSTR$(a+2^32,2)
END IF
LET BitPTN$=right$(a$,2^N)
END FUNCTION
!ÏÀÍý±é»»
EXTERNAL FUNCTION AND(a,b) !À°¿ôa,b¤Î¥Ó¥Ã¥Èñ°Ì¤Ç¤ÎÏÀÍýÀѤòµá¤á¤ë
LET c=0
FOR i=0 TO 31
LET aa=MOD(a,2)
LET a=(a-aa)/2
LET bb=MOD(b,2)
LET b=(b-bb)/2
LET c=c+MIN(aa,bb)*2^i
NEXT i
IF c>=2^31 THEN LET c=c-2^32
LET AND=c
END FUNCTION
EXTERNAL FUNCTION OR(a,b) !À°¿ôa,b¤Î¥Ó¥Ã¥Èñ°Ì¤Ç¤ÎÏÀÍýϤòµá¤á¤ë
LET c=0
FOR i=0 TO 31
LET aa=MOD(a,2)
LET a=(a-aa)/2
LET bb=MOD(b,2)
LET b=(b-bb)/2
LET c=c+MAX(aa,bb)*2^i
NEXT i
IF c>=2^31 THEN LET c=c-2^32
LET OR=c
END FUNCTION
EXTERNAL FUNCTION NT(a) !À°¿ôa¤Î¥Ó¥Ã¥Èñ°Ì¤Ç¤ÎÏÀÍýÈÝÄê¤òµá¤á¤ë¡¡¢¨NOT¤ÏͽÌó¸ì¤Î¤¿¤á
LET NT=-1-a
END FUNCTION
!-----------
! ¼Í±ÆÊÑ´¹ ( SAMPLE\TRANSFO9.BAS ¤«¤é¡¢ÇÒ¼Ú¡Ë
DIM T(4,4),m(501,501)
MAT T=IDN
PICTURE House
SET AREA COLOR 15
PLOT AREA: 0, 1;
0, 0; 2, 0;
2, 1 !ÊÉ
SET AREA COLOR 2
PLOT AREA: -0.6,1; 2.6, 1; 2, 2; 0, 2 !²°º¬
SET AREA COLOR 10
PLOT AREA: 0.1, 0; 0.1,0.8; 0.5,0.8; 0.5, 0 !¥É¥¢
SET AREA COLOR 5
PLOT AREA: 1.4,0.4; 1.9,0.4; 1.9,0.8; 1.4,0.8 !Áë
SET AREA COLOR 12
PLOT AREA: 1.7, 2; 1.7,2.3; 1.5,2.3; 1.5, 2 !±ìÆÍ
END PICTURE
!---------
!²èÁüÇÛÎó m(1~Xw,1~Yw) !! Ãí°Õ x,y ¤Î½ç mat read m(y,x)
SUB inppix !! ask pixel array(x0,y0) m(x,y)
LET lx=lx+1
IF Xw< lx THEN
LET lx=1
LET ly=ly+1
END IF
IF ly<=Yw THEN LET bx=m(lx,ly) ! data on bx
END SUB
SUB picture_data
PRINT #1: CHR$(obits0); !ºÇ¾®¥Ç¡¼¥¿¡¼¥Ó¥Ã¥ÈĹ ¡ÄͽÌóÅÐÏ¿ÈÖ¹æ¤ÎºÇÂç¥Ó¥Ã¥ÈĹ
LET blkfull=255 !block size max.(~~255)
LET bitfull=12 ! LZW bits max.(~~ 12)
CALL LZW_encoder
CALL outcode !flush registered dic.number on ax
LET ax=N000+1 !code end
CALL outcode
CALL out_flush
PRINT #1: CHR$(0); !block size 0 (end)
END SUB
SUB LZW_encoder
LET lx=1 -1 !²èÁüÇÛÎó m(1~Xw,1~Yw)
LET ly=1
CALL inppix !data on bx
LET pdata$="" !clear output bytes buffer
LET oacc$="" !clear output bits buffer
LET owidth=obits0+1 !starting bit width
DO
LET ax=N000 !reset code
CALL outcode
MAT dic_0=ZER !clear dic.number
MAT dic_1=ZER !clear dic.chain
LET
thead=1 !reset
make_table pointer
LET dicnum=N000+2 !reset dictionary new number
LET owidth=obits0+1 !starting bit width
DO
LET
di=0 !top
table
LET dic_0(di,bx)=bx
DO
LET
ax=dic_0(di,bx) !---latch last chained register
IF
dic_1(di,bx)>0 THEN LET di=dic_1(di,bx) ELSE CALL make_table
CALL
inppix !
next bx
IF Yw< ly THEN EXIT SUB
LOOP UNTIL dic_0(di,bx)=0 !---until no register
LET dic_0(di,bx)=dicnum ! new register, bx=tail
CALL
outcode !write
last register
LET owidth=LEN( BSTR$(dicnum,2) ) ! remake owidth
LET dicnum=dicnum+1
LOOP UNTIL dicnum>2^bitfull-1 OR thead>t_max !bits full or dic.full
LOOP
END SUB
SUB make_table
LET dic_1(di,bx)=thead !chained table pointer
LET di=thead !new table head
LET thead=thead+1
END SUB
SUB outcode
LET oacc$=right$("00000000000"& BSTR$(ax,2),owidth)& oacc$
DO WHILE LEN(oacc$)>=8
LET pdata$=pdata$& CHR$(BVAL(right$(oacc$,8),2))
LET oacc$=oacc$(1:LEN(oacc$)-8)
IF LEN(pdata$)=blkfull THEN CALL bw_sub
LOOP
END SUB
SUB bw_sub
PRINT #1: CHR$(LEN(pdata$)); pdata$;
LET pdata$=""
PRINT "thead=";thead;" dicnum=";dicnum !--monitor
END SUB
SUB out_flush
IF oacc$<>"" THEN LET pdata$=pdata$& CHR$(BVAL(oacc$,2) )
LET oacc$=""
IF pdata$>"" THEN CALL bw_sub
PRINT "------" !--monitor
END SUB
!=============
SUB gif_header
PRINT "½èÍýÃæ"
OPEN #1: NAME ofile$
ERASE #1
PRINT #1: "GIF89a";
CALL prt_2dw( Xw,Yw )
! ---sflg---
! 1: common-palet-ON
!xxx: colors_bits/pixel 2^(xxxb+1)
! 0: sort-OFF
!xxx: colors_bits/common-palet 2^(xxxb+1)
LET sflg=BVAL("10000000",2)+(obits0-1)*16+(obits0-1)
PRINT #1: CHR$(sflg);
PRINT #1: CHR$(0); ! back ground color
PRINT #1: CHR$(0); ! ¥¢¥¹¥Ú¥¯¥ÈÈæ if n=0 then 1:1 else H:V=(n+15):64
! common_palette
FOR i=0 TO 2^obits0-1
ASK COLOR MIX(i) r,g,b
PRINT #1: CHR$(r*255);CHR$(g*255);CHR$(b*255); ! R G B
NEXT i
END SUB
!60¤Î¾ì¹ç
PRINT 1+2+3+4+5+6+10+12+15+20+30+60
!¡ü¼ÂºÝ¤Ëµá¤á¤Æ¡¢¤½¤ÎϤò·×»»¤¹¤ë
LET n=60 !µá¤á¤ë¿ô
LET s=0 !ÏÂ
LET c=0 !¸Ä¿ô
FOR f=1 TO SQR(n) !¸Ä¿ô¤ÎȾʬ¤Þ¤Ç
IF MOD(n,f)=0 THEN !³ä¤êÀÚ¤ì¤ë¤Ê¤é
IF n/f=f THEN !¾¦¤È³ä¤Ã¤¿¿ô¤¬Æ±¤¸¤È¤¡¢£±¤Ä
!PRINT f
LET s=s+f
LET c=c+1
ELSE !¾¦¤È³ä¤Ã¤¿¿ô¤¬°Û¤Ê¤ë¤È¤¡¢¥Ú¥¢¤Çµá¤Þ¤ë
!PRINT f; n/f
LET s=s+f+n/f
LET c=c+2
END IF
END IF
NEXT f
PRINT "ÏÂ=";s, "¸Ä¿ô=";c
!¡üÁÇ°ø¿ôʬ²ò
!¡¡n=p^a*q^b*r^c* ¡Ä ¡¢ÁÇ¿ôp,q,r,¡Ä¡¢À°¿ôa,b,c,¡Ä ¤Ê¤é
!¡¡ÏÂ (p^0+p^1+p^2+ ¡Ä +p^a)*(q^0+q^1+q^2+ ¡Ä +q^b)*(r^0+r^1+r^2+ ¡Ä +r^c)* ¡Ä
!¡¡¸Ä¿ô (a+1)*(b+1)*(c+1)* ¡Ä
!60=2^2*3^1*5^1 ¤è¤ê
PRINT (2^0+2^1+2^2)*(3^0+3^1)*(5^0+5^1) !ÏÂ
PRINT (2+1)*(1+1)*(1+1) !¸Ä¿ô
!¤Þ¤¿¡¢¥«¥Ã¥³¤ÎÃæ¤ÏÅùÈæ¿ôÎó¤è¤ê¡¡¢¨ÏÂSn=a*(1-r^n)/(1-r)¡¢½é¹àa¡¢¸øÈær¡¢¹à¿ôn
LET t1=1*(1-2^3)/(1-2) !2^0+2^1+2^2
LET t2=1*(1-3^2)/(1-3) !3^0+3^1
LET t3=1*(1-5^2)/(1-5) !5^0+5^1
PRINT t1*t2*t3
!¡üÁÇ°ø¿ôʬ²ò¤Î¥×¥í¥°¥é¥à¤Ë¾åµ¤Î»»½ÐÊýË¡¤òÁȹþ¤à
LET n=60 !µá¤á¤ë¿ô
LET s=1 !ÏÂ
LET c=1 !¸Ä¿ô
LET f=2
DO UNTIL f>SQR(n)
LET k=0
DO WHILE MOD(n,f)=0 !³ä¤êÀÚ¤ì¤ë¤Ê¤é
!PRINT f;
LET k=k+1 !¸Ä¿ô
LET n=n/f
LOOP
LET s=s * 1*(1-f^(k+1))/(1-f) !ÅùÈæ¿ôÎó¤ÎÏ ¦²[i=0,k+1]f^i
LET c=c * (k+1) !0,1,2,¡Ä,k
LET f=f+1 !¼¡¤Ø
LOOP
IF n>1 THEN !»Ä¤ê¤Î°ø¿ô
!PRINT n
LET s=s * 1*(1-n^(1+1))/(1-n)
LET c=c * (1+1)
END IF
PRINT "ÏÂ=";s, "¸Ä¿ô=";c
! LZW ¥¨¥ó¥³¡¼¥À¡¼¤È¡¢¥Ç¥³¡¼¥À¡¼
!-----------
OPTION CHARACTER byte
DIM m(501,501)
LET obits0=2 !¡Ê 2= 2¿§~4¿§, 3= 8¿§, 4=16¿§, ¡Ä 8=256¿§)
LET N000=2^obits0 ! ¿§¿ô¡ÊͽÌó¤ÎÅÐÏ¿ÈÖ¹æºÇÂç+1¡Ë
!
LET t_max= 1000 !¡á»È¤ï¤ì¤¿¿§¿ô£ø¼½ñ¤Ø¤ÎÅÐϿʸ»ú¤ÎŤµ¡£(ÉÔ¾Ü)¡ÚµÕ°ú¤¼½ñ¡Û
! !
¡¡¾®¤µ¤¤¤È¼½ñ¥¯¥ê¥¢¡¼ÉÑÅÙÁý¤·¡¢°µ½Ì½ÐÎÏ¥µ¥¤¥º¤Ï¡¢°²½¤¹¤ë¤¬¡¢
! !¡¡¤½¤Îʬ¡¢Éü¸µÂ¦¤â¡¢¼½ñ¤Î¥á¥â¥ê¡¼¾ÃÈñ¤Ï¡¢¸º¤ë¡£
DIM dic_0(0 TO t_max, 0 TO N000-1), dic_1(0 TO t_max, 0 TO N000-1) !encoder ¼½ñ
!
LET blkfull=255 ! block size max.(~~255)
LET bitfull=12 ! LZW bits max.(~~ 12)
DIM dic$(0 TO 2^bitfull) ! decoder ¼½ñ¡¢¼ýǼ¤Ï¡¢¿·µ¬¤ÎÅÐÏ¿ÈÖ¹æºÇÂç¤Þ¤Ç¡£
!
!------------------- ¥Æ¥¹¥È¸¶²è¤ÎºîÀ® -----------------------------------
LET Xw=4
LET Yw=3
MAT m=ZER(Yw,Xw)
MAT READ m
!MAT m=BVAL("03",16)*CON(Yw,Xw)
! £´¿§(2bits) ²£:£´ ½Ä:£³ ¤Î¡¢¥Æ¥¹¥È¡¦¥Ñ¥¿¡¼¥ó
DATA 0,1,2,3
DATA 0,1,2,3
DATA 0,1,2,3
!
PRINT "******************* ¸¶²è¥Ñ¥¿¡¼¥ó"; Xw;"x";Yw
FOR j=1 TO Yw
LET ww$=""
FOR i=1 TO Xw
LET ww$=ww$& right$("0"& BSTR$(m(j,i),16),2)& " "
NEXT i
PRINT ww$
NEXT j
!
CALL picture_data !¡¡¾åµ¥Ñ¥¿¡¼¥ó¤ò ¼ÂºÝ¤Ë¡¢Encode ¤¹¤ë¡£¸¶²è¢ª LZW$
CALL decomp_data !¡¡¾å¤ÎEncode ½ÐÎϤò ¼ÂºÝ¤Ë¡¢Decode ¤¹¤ë¡£LZW$¢ª ¸¶²è
!------------------- ¸¶²è¤«¤é¡¢²èÁü¥Ç¡¼¥¿ LZW$ ¤ÎºîÀ®¡£------------------
!²èÁüÇÛÎó m(1~Yw,1~Xw) !! Ãí°Õ x,y ¤Î½ç mat read m(y,x)
SUB inppix !! ask pixel array(x0,y0) m(x,y)
LET lx=lx+1
IF Xw< lx THEN
LET lx=1
LET ly=ly+1
END IF
IF ly<=Yw THEN LET bx=m(ly,lx) ! data on bx
END SUB
SUB picture_data
PRINT "******************* °µ½Ì( LZW ¥¨¥ó¥³¡¼¥É )"
LET LZW$=CHR$(obits0)
CALL prthex(CHR$(obits0),"ºÇ¾®¥Ç¡¼¥¿¡¼¥Ó¥Ã¥ÈĹ") !ͽÌóÅÐÏ¿ÈÖ¹æºÇÂç¤Î¥Ó¥Ã¥ÈĹ
!---
CALL LZW_encoder
CALL
outcode !flush
last chained dic.number on ax
LET ax=N000+1
CALL outcode !code end
CALL out_flush
!---
LET LZW$=LZW$& CHR$(0) !block end
CALL prthex(CHR$(0),"block size") !¥â¥Ë¥¿¡¼
END SUB
SUB LZW_encoder
LET lx=1 -1 !²èÁüÇÛÎó start pointer
LET ly=1
CALL inppix !data on bx
LET pdata$="" !clear output byte buffer
LET oacc$="" !clear output bit buffer
LET owidth=obits0+1 !starting bit width
DO
LET ax=N000 !reset code
CALL outcode
MAT dic_0=ZER !clear dic.number
MAT dic_1=ZER !clear dic.chain
LET
thead=1 !reset
make_table pointer
LET dicnum=N000+2 !reset new dic.number
LET owidth=obits0+1 !starting bit width
DO
LET
di=0 !top
table
LET
dic_0(di,bx)=bx !bx as reserved
dic.number
DO
LET
ax=dic_0(di,bx) !---latch last chained dic.number
IF
dic_1(di,bx)>0 THEN LET di=dic_1(di,bx) ELSE CALL make_table
CALL
inppix !
next bx
IF Yw< ly THEN EXIT SUB
LOOP UNTIL dic_0(di,bx)=0 !---until no dic.number
LET dic_0(di,bx)=dicnum ! new dic.number, bx as tail& next top
CALL
outcode !
write ax, last chained dic.number
LET owidth=LEN( BSTR$(dicnum,2) ) ! remake owidth
LET dicnum=dicnum+1
LOOP UNTIL dicnum>2^bitfull-1 OR thead>t_max !bits full or dic.full
LOOP
END SUB
SUB make_table
LET dic_1(di,bx)=thead !chained table pointer
LET di=thead !new table head
LET thead=thead+1
END SUB
SUB outcode
LET oacc$=right$("00000000000"& BSTR$(ax,2),owidth)& oacc$
DO WHILE LEN(oacc$)>=8
LET pdata$=pdata$& CHR$(BVAL(right$(oacc$,8),2))
LET oacc$=oacc$(1:LEN(oacc$)-8)
IF blkfull=LEN(pdata$) THEN CALL bw_sub
LOOP
END SUB
SUB bw_sub
LET LZW$=LZW$& CHR$(LEN(pdata$))& pdata$
CALL prthex( CHR$(LEN(pdata$)),"block size") !¥â¥Ë¥¿¡¼
CALL prthex( pdata$,"LZW compression bit stream") !¥â¥Ë¥¿¡¼
LET pdata$=""
END SUB
SUB out_flush
IF oacc$<>"" THEN LET pdata$=pdata$& CHR$(BVAL(oacc$,2) )
LET oacc$=""
IF pdata$>"" THEN CALL bw_sub
END SUB
!---------------- ¥â¥Ë¥¿¡¼¶¦Ḁ̈ѡ¼¥Ä
SUB prthex(d$,w$)
LET ww$=""
FOR ii=1 TO LEN(d$)
LET ww$=ww$& right$("0"& BSTR$(ORD(d$(ii:ii)),16),2)& " "
NEXT ii
IF w$>"" THEN LET ww$=ww$& "; "& w$
PRINT ww$
END SUB
!------------------- ²èÁü¥Ç¡¼¥¿ LZW$ ¤«¤é¡¢¸¶²è¤ØÌ᤹¡£------------------
SUB decomp_data
PRINT "******************* Éü¸µ( LZW ¥Ç¥³¡¼¥É )"
LET obits0=ORD(LZW$(1:1))
CALL prthex(CHR$(obits0),"ºÇ¾®¥Ç¡¼¥¿¡¼¥Ó¥Ã¥ÈĹ") !¥â¥Ë¥¿¡¼
LET N000=2^obits0
LET
li=2
!start input pointer
LET
blkend=0
!clear input block pointer
LET
iacc$=""
!clear input bit buffer
LET
pdata$="" !clear
output byte buffer
CALL LZW_decoder
FOR i=1 TO LEN(pdata$) STEP Xw
CALL prthex(pdata$(i:i+Xw-1),"") !¥â¥Ë¥¿¡¼
NEXT i
!--- check block_end
CALL prthex( LZW$(li:li),"block size") !¥â¥Ë¥¿¡¼
END SUB
SUB LZW_decoder
DO
LET
dicnum=N000+2-1
!start dic.number-1
DO
LET iwidth=LEN( BSTR$(dicnum,2) ) !remake iwidth
IF bitfull< iwidth THEN LET iwidth=bitfull !to handle BAD encode
LET dicnum=dicnum+1
CALL
inpcode
!data on bx
IF bx=-1 OR bx=N000+1 THEN
EXIT SUB
ELSEIF bx=N000 THEN
EXIT DO
ELSE
IF bx< N000 THEN
LET dic$(dicnum)=CHR$(bx)
ELSE
LET dic$(dicnum)=dic$(bx)
LET dic$(dicnum)=dic$(dicnum)& dic$(bx+1)(1:1)
END IF
LET pdata$=pdata$& dic$(dicnum)
END IF
LOOP
LOOP
END SUB
SUB inpcode
LET bx=-1
DO WHILE LEN(iacc$)< iwidth
IF blkend<=li THEN
LET blksize=ORD(LZW$(li:li))
CALL prthex(CHR$(blksize),"block size") !¥â¥Ë¥¿¡¼
IF blksize=0 THEN EXIT SUB
LET li=li+1
LET blkend=li+blksize
END IF
LET iacc$=right$("0000000"& BSTR$(ORD(LZW$(li:li)),2),8)& iacc$
LET li=li+1
LOOP
LET bx=BVAL(right$(iacc$,iwidth),2)
LET iacc$=iacc$(1:LEN(iacc$)-iwidth)
END SUB
!¡ü¿ôÎó¤Ë¤è¤ë¥¢¥×¥í¡¼¥Á
!Îã. n=9¤Î¾ì¹ç
!¡¡1+2+3+4+5+ ¡Ä +9¡¡£´¤Ç¾ò·ï¤òËþ¤¿¤µ¤Ê¤¤
!¡¡¡¡2+3+4+5+ ¡Ä +9¡¡£´¤Ç¾ò·ï¤òËþ¤¿¤¹
!¡¡¡¡¡¡3+4+5+ ¡Ä +9¡¡£µ¤Ç¾ò·ï¤òËþ¤¿¤µ¤Ê¤¤
!¡¡¡¡¡¡¡¡4+5+ ¡Ä +9¡¡£µ¤Ç¾ò·ï¤òËþ¤¿¤¹
!¡¡¡¡¡¡¡¡¡¡¡§
!¡¡¡¡¡¡¡¡¡¡¡¡ 7+8+9¡¡£¸¤Ç¾ò·ï¤òËþ¤¿¤µ¤Ê¤¤
!¡¡¡¡¡¡¡¡¡¡¡¡¡¡ 8+9¡¡£¹¤Ç¾ò·ï¤òËþ¤¿¤µ¤Ê¤¤
!¹â¡¹n¤Þ¤Ç¤ÎϤòµá¤á¤Æ¡¢¸µ¤Î¿ô¤ËÅù¤·¤¯¤Ê¤ë¤«³Îǧ¤¹¤ë
LET n=9 !µá¤á¤ë¿ô
FOR a=1 TO n-1 !½é¹à
LET s=0
FOR m=a TO n !¹â¡¹£î¤Þ¤Ç¤ÎÏÂ
LET s=s+m
IF s=n THEN !Åù¤·¤¤¤Ê¤é
FOR k=a TO m !·ë²Ì¤òɽ¼¨¤¹¤ë
PRINT "+";k;
NEXT k
PRINT "=";s !¸¡»»
END IF
IF s>=n THEN EXIT FOR !¤³¤ì°Ê¹ß¤Ï¾ò·ï¤òËþ¤¿¤µ¤Ê¤¤¤Î¤Ç¡¢¼¡¤Ø
NEXT m
NEXT a
!¡üÊ̲ò
LET n=9 !µá¤á¤ë¿ô
FOR a=1 TO n-1 !½é¹à
LET d=1 !½é¹àa¡¢¸øº¹d¤ÎÅùº¹¿ôÎó¤ÎÂèm¹à¤Þ¤Ç¤ÎÏÂ
FOR m=1 TO n !¹â¡¹£î¹à¤Þ¤Ç
LET s=m*(2*a+(m-1)*d)/2 !Ϥθø¼°
IF s=n THEN !Åù¤·¤¤¤Ê¤é
FOR k=1 TO m !·ë²Ì¤òɽ¼¨¤¹¤ë
PRINT "+";a+(k-1)*d; !°ìÈ̹à¤Î¸ø¼°
NEXT k
PRINT "=";s !¸¡»»
END IF
IF s>=n THEN EXIT FOR !¤³¤ì°Ê¹ß¤Ï¾ò·ï¤òËþ¤¿¤µ¤Ê¤¤¤Î¤Ç¡¢¼¡¤Ø
NEXT m
NEXT a
!¡ü£²¼¡ÊýÄø¼°¤Î²ò¤Ë¤è¤ë¥¢¥×¥í¡¼¥Á
!Îã. n=9¤Î¾ì¹ç
!¡¡¡¡1+2+3+4+5+ ¡Ä +t¡¡a=1¡¢t=3.772¡Ä
!¡¡1+¡¡2+3+4+5+ ¡Ä +t¡¡a=2¡¢t=4
!¡¡1+2+¡¡3+4+5+ ¡Ä +t¡¡a=3¡¢t=4.424¡Ä
!¡¡1+2+3+¡¡4+5+ ¡Ä +t¡¡a=4¡¢t=5
!¡¡¡¡¡¡¡¡¡¡¡§
!¡¡1+2+3+4+5+6+ 7+8+t¡¡a=7¡¢t=7.262¡Ä
!¡¡1+2+3+4+5+6+7+ 8+t¡¡a=8¡¢t=8.116¡Ä
!1¡Ák¤Þ¤Ç¤ÎϤÏk*(k+1)/2¤è¤ê¡¢a,a+1,¡Ä,t¤Þ¤Ç¤ÎϤϡ¢t*(t+1)/2-(a-1)*a/2¤È¤Ê¤ë¡£
!¤³¤ì¤¬n¤ÈÅù¤·¤¤¡£a¤ò¸ÇÄꤹ¤ë¤È¡¢£²¼¡ÊýÄø¼° t^2+t-(2*n+(a-1)*a)=0 ¤Î²ò¤È¤Ê¤ë¡£
LET n=9 !µá¤á¤ë¿ô
FOR a=1 TO n-1 !a¤ò¸ÇÄꤹ¤ë
LET D=1*1-4*1*(-(2*n+(a-1)*a)) !ȽÊ̼°
IF D>=0 THEN !¼Â¿ô²ò¤Ê¤é
LET t=(-1+SQR(D))/2 !£±¤ÄÌܤβò
!PRINT a;t !debug
IF t>0 AND INT(t)=t THEN !t¤Ï¼«Á³¿ô¤Ê¤é
FOR k=a TO t !·ë²Ì¤òɽ¼¨¤¹¤ë
PRINT "+";k;
NEXT k
PRINT "=";t*(t+1)/2-(a-1)*a/2 !¸¡»»
END IF
LET t=(-1-SQR(D))/2 !£²¤ÄÌܤβò¡¡¢¨¤³¤Á¤é¤¬¾ò·ï¤òËþ¤¿¤¹¤³¤È¤Ï¤Ê¤¤
!PRINT a;t !debug
IF t>0 AND INT(t)=t THEN
FOR k=a TO t
PRINT "+";k;
NEXT k
PRINT "=";t*(t+1)/2-(a-1)*a/2
END IF
END IF
NEXT a
!¡üÌó¿ô¤Ë¤è¤ë¥¢¥×¥í¡¼¥Á
!Îã. n=9¤Î¾ì¹ç
!¡¡Ìó¿ô¤Ï1,3,9¡££±¤ò½ü¤¯´ñ¿ô¤ÎÌó¿ô¤ËÃåÌܤ¹¤ë¡£
!¡¡¤¿¤È¤¨¤Ð¡¢£î¤¬£³¤Ç³ä¤êÀÚ¤ì¤ë¤³¤È¤è¤ê¡¢£³Åùʬ¤Ç¤¤ë¡£¤¹¤Ê¤ï¤Á¡¢n=9=3+3+3¤È¤Ê¤ë¡£
!¡¡£³¤Î¤È¤¡¢n=3+(3)+3=(3-1)+£³+(3+1)=2+£³+4 ¤È¿¿¤óÃæ¤Î£³¤ò´ð½à¤Ë¡¢ÊÑ·Á¤¹¤ë¡£
!¡¡£¹¤Î¤È¤¡¢n=1+1+1+1+(1)+1+1+1+1
!¡¡¡¡¡¡¡¡¡¡¡¡ =(1-4)+(1-3)+(1-2)+(1-1)+£±+(1+1)+(1+2)+(1+3)+(1+4)
!¡¡¡¡¡¡¡¡¡¡¡¡ =(-3)+(-2)+(-1)+0+£±+2+3+4+5
!¡¡¡¡¡¡¡¡¡¡¡¡ =4+5
LET n=9 !µá¤á¤ë¿ô
FOR f=2 TO n !£±¤ò½ü¤¯Ìó¿ô¤ò¤ß¤Ä¤±¤ë
IF MOD(n,f)=0 THEN
IF MOD(f,2)=1 THEN !´ñ¿ô¤ËÃåÌܤ¹¤ë
LET c=INT(f/2)+1 !¿¿¤óÃæ¤Î°ÌÃÖ¤òÆÀ¤Æ¡¢¤½¤ì¤ò´ð½à¤ËÊÑ·Á¤¹¤ë
LET s=0 !Á껦Éôʬ¤ÎÈϰϤòÆÀ¤ë
FOR i=1 TO f
LET k=n/f + (i-c) !fÅùʬ¡Þ1,2,3,¡Ä
!PRINT i;k !debug
LET s=s+k
IF s>0 THEN PRINT "+";k;
NEXT i
PRINT "=";s !¸¡»»
END IF
END IF
NEXT f
!¡üÊ̲ò¡¡´ñ¿ô¤¬Ï¢Â³¤¹¤ë£²¤Ä¤Î¼«Á³¿ô¤ÎϤÇɽ¤µ¤ì¤ë
!Îã. n=9¤Î¾ì¹ç
!¡¡Ìó¿ô¤Ï1,3,9¡££±¤ò½ü¤¯´ñ¿ô¤ÎÌó¿ô¤ËÃåÌܤ¹¤ë¡£
!¡¡¤¿¤È¤¨¤Ð¡¢£î¤¬£³¤Ç³ä¤êÀÚ¤ì¤ë¤³¤È¤è¤ê¡¢£³¤ÏÇÜ¿ô¤È¤Ê¤ë¡£¤¹¤Ê¤ï¤Á¡¢n=£³*3=£³+£³+£³¡£
!¡¡¤³¤Î£³¤òϢ³¤¹¤ë£²¤Ä¤Î¼«Á³¿ô¤ÎϤÇɽ¤¹¤È¡¢3=£±+£²¡£
!¡¡»Ä¤ê¤Î£³¤â¡¢¤³¤ì¤ò´ð½à¤Ë£±¡Ý1,2,3,¡Ä¡¢£²¡Ü1,2,3,¡Ä¤ÎϤÇɽ¤¹¡£
!¡¡£³¤Î¤È¤¡¢n=3*3=3+3+3=(1+2)+(0+3)+(-1+4)=-1+0+1+2+3+4=2+3+4 ¤ÈÊÑ·Á¤¹¤ë¡£
!¡¡£¹¤Î¤È¤¡¢n=9*1=9=(4+5)
LET n=9 !µá¤á¤ë¿ô
FOR f=2 TO n !Ìó¿ô¤ò¤ß¤Ä¤±¤ë
IF MOD(n,f)=0 THEN
IF MOD(f,2)=1 THEN !´ñ¿ô¤ËÃåÌܤ¹¤ë
LET c=(f-1)/2 !Ϣ³¤¹¤ë£²¤Ä¤Î¼«Á³¿ôc,c+1¤ÎϤˤ¹¤ë
LET s=0 !Á껦Éôʬ¤ÎÈϰϤòÆÀ¤ë
FOR k=c-n/f+1 TO c+n/f !ÊÑ·Á¤·¤¿¼°¤ò·×»»¤¹¤ë
!PRINT k !debug
LET s=s+k
IF s>0 THEN PRINT "+";k;
NEXT k
PRINT "=";s !¸¡»»
END IF
END IF
NEXT f
END
!Page-2 ¤Î»Ï¤á
!------------------- ²èÁü¥Ç¡¼¥¿ LZW$ ¤«¤é¡¢¸¶²è¤ò¸«¤ë¡£------------------
SUB decomp_data
PRINT "******************* Éü¸µ( LZW ¥Ç¥³¡¼¥É )"
LET obits0=ORD(LZW$(1:1))
CALL prthex(CHR$(obits0),"ºÇ¾®¥Ç¡¼¥¿¡¼¥Ó¥Ã¥ÈĹ") !¥â¥Ë¥¿¡¼
LET N000=2^obits0
LET
li=2
!start input pointer
LET
blkend=0
!clear input block pointer
LET
iacc$=""
!clear input bit buffer
LET
pdata$="" !clear
output byte buffer
CALL LZW_decoder
PRINT "Last_code LEN(LZW$) LEN(pdata$)=";bx;LEN(LZW$);LEN(pdata$) !¥â¥Ë¥¿¡¼
!---
IF tmod=3 THEN MAT m3=m
LET ii=1
IF interl=0 THEN
CALL intlace( 0, 1) ! start_raster, step !---NO interlace
ELSE
CALL intlace( 0, 8) ! start_raster, step !---0~7step8
WAIT DELAY .5
CALL intlace( 4, 8) ! start_raster, step !---4~7step8
WAIT DELAY .5
CALL intlace( 2, 4) ! start_raster, step !---2~3step4
WAIT DELAY .5
CALL intlace( 1, 2) ! start_raster, step !---1~1step2
END IF
IF tmod=2 THEN MAT m=ncp(256)*CON ! 256= ¥·¥¹¥Æ¥àÇØ·Ê¿§
IF tmod=3 THEN MAT m=m3
!--- check block_end
CALL prthex( LZW$(li:li),"block size") !¥â¥Ë¥¿¡¼
PRINT "******************* Éü¸µ½ª¤ê"
END SUB
SUB intlace( ss, stp)
FOR j=Yp0 TO Yp0+Ypw-1
IF MOD(j-Yp0, stp) >=ss THEN
IF MOD(j-Yp0, stp) >ss THEN LET ii=ii-Xpw
FOR i=Xp0 TO Xp0+Xpw-1
WHEN EXCEPTION IN
LET col=ORD(pdata$(ii:ii))
IF t_on<>1 OR tcol<>col THEN LET m(i,j)=ncp(col)
LET ii=ii+1
USE
END WHEN
NEXT i
END IF
NEXT j
MAT PLOT CELLS,IN 0,0; Xsw-1,Ysw-1 :m
END SUB
!-------------
SUB LZW_decoder
DO
LET
dicnum=N000+2-1
!start dic.number-1
DO
LET iwidth=LEN( BSTR$(dicnum,2) ) !remake iwidth
IF bitfull< iwidth THEN LET iwidth=bitfull !to handle BAD file
LET dicnum=dicnum+1
CALL
inpcode
!data on bx
IF bx=-1 OR bx=N000+1 THEN
EXIT SUB
ELSEIF bx=N000 THEN
EXIT DO
ELSE
IF bx< N000 THEN
LET dic$(dicnum)=CHR$(bx)
ELSE
LET dic$(dicnum)=dic$(bx)
LET dic$(dicnum)=dic$(dicnum)& dic$(bx+1)(1:1)
END IF
LET pdata$=pdata$& dic$(dicnum)
END IF
LOOP
LOOP
END SUB
SUB inpcode
LET bx=-1
DO WHILE LEN(iacc$)< iwidth
IF blkend<=li THEN
LET blksize=ORD(LZW$(li:li))
CALL prthex(CHR$(blksize),"block size") !¥â¥Ë¥¿¡¼
IF blksize=0 THEN EXIT SUB
LET li=li+1
LET blkend=li+blksize
END IF
LET iacc$=right$("0000000"& BSTR$(ORD(LZW$(li:li)),2),8)& iacc$
LET li=li+1
LOOP
LET bx=BVAL(right$(iacc$,iwidth),2)
LET iacc$=iacc$(1:LEN(iacc$)-iwidth)
END SUB
SUB prthex(d$,w$)
LET ww$=""
FOR ii=1 TO LEN(d$)
LET ww$=ww$& right$("0"& BSTR$(ORD(d$(ii:ii)),16),2)& " "
NEXT ii
IF w$>"" THEN LET ww$=ww$& "; "& w$
PRINT ww$
END SUB
! GIF ¥Õ¥¡¥¤¥ë¤Î²òÀϥġ¼¥ë Ver.2¡Ê²èÁüÉÕ¡Ë
!-------
! ¥ê¥¹¥Èº¸Ã¼¥¢¥É¥ì¥¹¤ò£µ·å¤Ë¤·¤¿¡£¥ê¥¹¥ÈÃí¼á¤òÂçÉý½¤Àµ¡£Éü¸µ²èÁü¤â¡¢
! ɽ¼¨¤¹¤ëÍͤˤ·¤¿¡£IE6 ¤Ï¡¢¥¹¥¯¥ê¡¼¥óÇØ·Ê¿§¤ò̵»ë¤·¤Æ¡¢¥Ö¥é¥¦¥¶ÇØ·Ê
! ¤Î¤ß¤ò¡¢ÂåÍѤ¹¤ë¤è¤¦¤Ê¤Î¤Ç¡¢£Ç£É£Æ»ÅÍͤ«¤é³°¤ì¤ë¤¬¡¢¤½¤ì¤Ë¹ç¤»¤¿¡£
! Disposal Method 0,1,2,3 ¡¢¥¤¥ó¥¿¥ì¡¼¥¹²èÁü¤Ê¤É¤¬¡¢¥â¥Ë¥¿¡¼½ÐÍè¤ë¡£
!
OPTION CHARACTER BYTE
LET bitfull=12 ! LZW max.bits (~~ 12)
DIM dic$(0 TO 2^bitfull) ! decoder ¼½ñ
!
FILE GETNAME file$, "gif"
IF file$="" THEN
PRINT "ÆþÎÏ¥Õ¥¡¥¤¥ë̾¤¬¡¢¤¢¤ê¤Þ¤»¤ó¡£"
STOP
END IF
!
PRINT "ÆþÎÏ¥Õ¥¡¥¤¥ë¡§"& file$
OPEN #1: NAME file$, ACCESS INPUT
PRINT "---------"
SET COLOR mode "native"
DIM ncp(0 TO 256) ! native color palette
LET ncp(256)=BVAL("eeeedd",16) ! 256= ¥·¥¹¥Æ¥àÇØ·Ê¿§ BGR
SET AREA COLOR ncp(256)
PLOT AREA: 0,0;1,0;1,1;0,1
CALL gif_head
LET i=MAX( Xsw,Ysw )
SET WINDOW -.1*i,1.1*i, 1.1*i,-.1*i
SET LINE STYLE 3
PLOT LINES:-1,-1;Xsw+.5,-1;Xsw+.5,Ysw+.5;-1,Ysw+.5;-1,-1
DIM m(0 TO Xsw-1,0 TO Ysw-1), m3(0 TO Xsw-1,0 TO Ysw-1)
MAT m=ncp(256)*CON
DO
CALL blocks_main
LOOP UNTIL b1$=CHR$(BVAL("3B",16))
PRINT "GIF ½ªÃ¼¥Ö¥í¥Ã¥¯"
CALL dump(b1$,2,"block label")
PRINT "---------"
CLOSE #1
!----
SUB gif_head
LET h$=""
CALL readb( h$,13 )
IF h$(1:3)="GIF" THEN PRINT "GIF ¥Ø¥Ã¥À¡¼" ELSE CALL error
LET Xsw= ORD(h$( 8: 8))*256+ORD(h$(7:7))
LET Ysw= ORD(h$(10:10))*256+ORD(h$(9:9))
LET sflg=ORD(h$(11:11)) ! ¥¹¥¯¥ê¡¼¥ó¾ðÊó¤Î¥Õ¥é¥°
LET BGco=ORD(h$(12:12))
LET aspect=ORD(h$(13:13))
LET b$=right$("0000000"& BSTR$(sflg,2) ,8)
LET colpix=2^(BVAL(b$(2:4),2)+1)
LET compal=2^(BVAL(b$(6:8),2)+1)
CALL dump(h$( 1: 6),6,"Asc") ! GIF¼±ÊÌʸ»ú
CALL dump(h$( 7: 8),2,"screen X_width= "& STR$(Xsw))
CALL dump(h$( 9:10),2,"screen Y_width= "& STR$(Ysw))
CALL dump(h$(11:11),2,"flags= "& b$ )
PRINT TAB(13);b$(1:1);":common_palette on=1/off=0"
PRINT TAB(11);b$(2:4);":colors/pixel 2^(";b$(2:4);"b+1)= ";STR$(colpix)
PRINT TAB(13);b$(5:5);":sort on=1/off=0 ¥Ñ¥ì¥Ã¥È¤Î¡¢½ÅÍ×ÅÙ ¿§½ç¥½¡¼¥È"
PRINT TAB(11);b$(6:8);":common_palette colors 2^(";b$(6:8);"b+1)= ";STR$(compal)
CALL dump(h$(12:12),2,"back_ground color= "& STR$(BGco))
IF aspect=0 THEN LET b$=".." ELSE LET b$=STR$(aspect)
CALL dump(h$(13:13),2,"¥¢¥¹¥Ú¥¯¥ÈÈæ H:V=, 0 ¤Ï 1:1 ¤½¤Î¾("& b$& "+15):64" )
CALL palette("common_¥Ñ¥ì¥Ã¥È", c_p$, sflg)
END SUB
!----
SUB blocks_main
LET b1$=""
CALL readb( b1$, 1)
IF b1$=CHR$(BVAL("21",16)) THEN !Äɲåǡ¼¥¿¡¦¥Ö¥í¥Ã¥¯
CALL option_block
ELSEIF b1$=CHR$(BVAL("2C",16)) THEN !²èÁü¥Ö¥í¥Ã¥¯
CALL picture_block
ELSEIF b1$=CHR$(BVAL("3B",16)) THEN !GIF ½ªÃ¼¥Ö¥í¥Ã¥¯
ELSE
CALL error
END IF
END SUB
!-------
SUB blocks(d$,m,t$,n) ! d$=data, m=byte/¹Ô, t$=Ãí¼á, n=Í×µáblocks
FOR n=1 TO n
CALL
readb(d$,1)
! w9$= readb_last_byte ! =block Size
CALL dump(w9$,1,"block size")
IF w9$=CHR$(0) THEN EXIT SUB ! block End
LET s=LEN(d$)
CALL readb(d$,ORD(w9$)) ! block data
IF 0< m THEN CALL dump(d$(s+1:LEN(d$)),m,t$)
NEXT n
END SUB
SUB readb(d$,cx) !cx=bytes size
FOR i=1 TO cx
CHARACTER INPUT #1,IF MISSING THEN EXIT FOR :w9$
LET d$=d$& w9$
NEXT i
IF i<=cx THEN CALL error
END SUB
SUB dump(d$,m,t$) ! t$="comment" ¢ª;comment t$="Asc" ¢ª;"ascii.dump"
FOR j=1 TO LEN(d$) STEP m
LET ww$=right$("0000"& BSTR$(adr,16),5)& " "
FOR i=j TO MIN(j+m-1, LEN(d$))
LET ww$=ww$& " "& right$("0"& BSTR$( ORD(d$(i:i)),16),2)
LET adr=adr+1
NEXT i
IF t$>"" THEN
LET ww$=ww$& REPEAT$(" ",6+3*m-LEN(ww$))
IF t$="Asc"
THEN !
ascii.dump
LET ww$=ww$& " ;"""
FOR i=j TO MIN(j+m-1, LEN(d$))
IF " "<=d$(i:i) THEN LET ww$=ww$& d$(i:i) ELSE LET ww$=ww$&
"."
NEXT i
LET ww$=ww$& """"
ELSE
IF
m=3 THEN LET ww$=ww$& " ;"& STR$(IP(j/3)) ! ¥Ñ¥ì¥Ã¥È¿§ÈÖ¹æ
IF
j=1 THEN LET ww$=ww$& " ;"&
t$ !
comment
END IF
END IF
PRINT ww$ ! ¹Ôñ°Ì¡¢¥Æ¥¥¹¥È²èÌ̤Υԥ«¤Ä¤¸º¾¯¡¢¹â®¡£
NEXT j
END SUB
!-------
SUB picture_block
PRINT "²èÁü¥Ö¥í¥Ã¥¯"
LET pi$=b1$
CALL readb( pi$,9)
CALL dump(pi$(1:1),2,"block label")
LET Xp0=ORD(pi$(3:3))*256+ORD(pi$(2:2))
LET Yp0=ORD(pi$(5:5))*256+ORD(pi$(4:4))
LET Xpw=ORD(pi$(7:7))*256+ORD(pi$(6:6))
LET Ypw=ORD(pi$(9:9))*256+ORD(pi$(8:8))
CALL dump(pi$(2:3),2,"picture.X0_position left= "& STR$(Xp0))
CALL dump(pi$(4:5),2,"picture.Y0_position top= "& STR$(Yp0))
CALL dump(pi$(6:7),2,"picture.X_width= "& STR$(Xpw))
CALL dump(pi$(8:9),2,"picture.Y_width= "& STR$(Ypw))
LET pflg=ORD(pi$(10:10)) ! ²èÁü¾ðÊó¤Î¥Õ¥é¥°
LET b$=right$("0000000"& BSTR$(pflg,2),8)
CALL dump(pi$(10:10),2,"flags= "& b$ )
LET interl=VAL(b$(2:2))
LET pripal=2^(BVAL(b$(6:8),2)+1)
PRINT TAB(13);b$(1:1);":private_palette on=1/off=0"
PRINT TAB(13);b$(2:2);":interlace on=1/off=0, 1~step8 5~step8 3~step4 2~step2"
PRINT TAB(13);b$(3:3);":sort on=1/off=0 ¥Ñ¥ì¥Ã¥È¤Î¡¢½ÅÍ×ÅÙ ¿§½ç¥½¡¼¥È"
PRINT TAB(12);b$(4:5);":blank"
PRINT TAB(11);b$(6:8);":private_palette colors 2^(";b$(6:8);"b+1)= ";STR$(pripal)
CALL palette("private_¥Ñ¥ì¥Ã¥È", p_p$, pflg)
!---
PRINT "²èÁü¥Ç¡¼¥¿"
LET LZW$=""
CALL readb( LZW$,1)
CALL dump(LZW$,1,"ºÇ¾®¥Ç¡¼¥¿¡¦¥Ó¥Ã¥ÈĹ")
!--- LZW ¥Ç¡¼¥¿¡Êsize:data, size:data, ¡Ä 0 ¡Ë
CALL blocks(LZW$,16,"",9999) ! (data, byte/¹Ô, Ãí¼á, Í×µáblocks)
CALL decomp_data
END SUB
SUB palette(n$, p$, pf)
PRINT n$;
LET p$=""
IF IP(pf/128)>0 THEN ! pf AND 0x80
PRINT
CALL readb(p$, 3*2^(MOD(pf,8)+1)) ! pf AND 0x07
CALL dump(p$,3,"R G B")
CALL palette10(n$, p$, pf)
ELSE
LET ww$=" ̵¤·¡£"
IF n$(1:1)="p" AND c_p$>"" THEN
LET ww$=ww$& "¢ª common_¥Ñ¥ì¥Ã¥È »ÈÍÑ¡£"
IF bk_p$(1:1)<>"c" THEN CALL palette10("common", c_p$, sflg)
END IF
PRINT ww$
END IF
END SUB
SUB palette10(n$, p$, pf)
FOR i=1 TO 3*2^(MOD(pf,8)+1) STEP 3
LET ncp(IP(i/3))= ORD(p$(i:i))+256*ORD(p$(i+1:i+1))+65536*ORD(p$(i+2:i+2))
NEXT i
LET bk_p$=n$
END SUB
SUB error
beep
PRINT "File Error Stop"
STOP
END SUB
100 LET a=1 !¸Å¤¤b
110 LET b=0 !A[0]
120 LET n=0 !¹à
130 IF n=20 THEN GOTO 190 !Â裲£°¹à¤Þ¤Ç
140 LET n=n+1
150 LET b=a+b !=a[n-2]+a[n-1]=A[n]¡Ê=¸Å¤¤b+b¡Ë
160 LET a=b-a !a=b-a=A[n]-a[n-1]=a[n-2]=¸Å¤¤b
170 PRINT n; a; b !Âè£î¹à¤òɽ¼¨¤¹¤ë
180 GOTO 130
190 END
!¥æ¡¼¥¯¥ê¥Ã¥É¤Î¸ß½üË¡¤Ç¡¢4181¤È6765¤È¤ÎºÇÂç¸øÌó¿ô¤òµá¤á¤ë
LET a=4181 !¢¨a< b
LET b=6765
PRINT b
DO WHILE a<>b !a=b¤Ê¤é½ªÎ»
IF a>b THEN
LET a=a-b !¡Öa-b¤Èb¤È¤ÎºÇÂç¸øÌó¿ô¤òµá¤á¤ë¡×¤ËÃÖ¤´¹¤¨¤ë
PRINT b !trace
ELSE
LET b=b-a
PRINT a !trace
END IF
LOOP
PRINT a !ºÇÂç¸øÌó¿ô
!¤½¤Î£²¡¡¾ê;¤ò»È¤Ã¤¿¾ì¹ç
LET a=4181 !¢¨b¤ò½ÐÎϤ¹¤ë¤¿¤á¤Ë¤Ï¡¢a< b¤È¤¹¤ë
LET b=6765
DO UNTIL b=0
LET t=b
LET b=MOD(a,b)
LET a=t
PRINT a !trace
LOOP
PRINT a !ºÇÂç¸øÌó¿ô
END
100 LET a=1 !´ñ¿ô¤Î¹à: a[-1]
110 LET b=0 !¶ö¿ô¤Î¹à: a[0]
120 LET n=0 !ÁÈ
130 IF n=10 THEN GOTO 190 !£±£°ÁȤޤÇ
140 LET n=n+1
150 LET a=a+b !=a[k-1]+a[k]=a[k+1]
160 LET b=b+a !=b+(a+b)=2*b+a=2*a[k]+a[k-1]=a[k]+(a[k-1]+a[k])=a[k]+a[k+1]=a[k+2]
170 PRINT a; b !£²¿ô
180 GOTO 130
190 END
SQR´Ø¿ô¤Ï¡¤ÊгѤ¬¡Ý¦Ð/2¤è¤êÂç¤Ç¦Ð/2°Ê²¼¤Ç¤¢¤ëÊ¿Êýº¬¤òÊÖ¤¹¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£
¼¡¤Î¤è¤¦¤ËÊ¿Êýº¬´Ø¿ôsqrt¤òÄêµÁ¤¹¤ì¤Ð¡¤ÊгѤ¬0°Ê¾å¦Ð̤Ëþ¤Ç¤¢¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
FUNCTION sqrt(x)
LET x=SQR(x)
IF x<>0 AND ARG(x)<0 THEN
LET x=x*(-1)
END IF
LET sqrt=x
END FUNCTION
! °Ê²¼¡¤»ÈÍÑÎã
LET x=COMPLEX(-1/2,-SQR(3)/2)
PRINT SQR(x),sqrt(x)
END
Ê£ÁÇ´Ø¿ô¤Î¾ÜºÙ¤Ï¡¤¥Ø¥ë¥×¤ÎÊ£ÁÇ´Ø¿ô¤Î¥Ú¡¼¥¸¤ò¸«¤Æ¤¯¤À¤µ¤¤¡£
(1) FACT(x)¤ò2¿Ê¥â¡¼¥É,Ê£ÁÇ¿ô¥â¡¼¥É¤Ç¼Â¹Ô¤·¤¿¾ì¹ç¡¢x¤¬¾®¿ô¤Î¤È¤Îã³°¤È¤Ê¤é¤º¸í¤Ã¤¿ÃͤòÊÖ¤¹¡£
100 OPTION ARITHMETIC NATIVE
110 FOR x=-1 TO 4
120 WHEN EXCEPTION IN
130 PRINT x;FACT(x) ! À°¿ô¤Ç¤ÏÌäÂê¤Ê¤¤
140 USE
150 END WHEN
160 NEXT x
170 PRINT
180 FOR x=-1 TO 4.0001 STEP 0.1
190 WHEN EXCEPTION IN
200 PRINT x;FACT(x) ! x<-0.5¤Ç¤ÏÎã³°¤¬È¯À¸
210 USE
220 END WHEN
230 NEXT x
240 END
¾åµ¥×¥í¥°¥é¥à¤ò10¿Ê15·å,1000·å,ÍÍý¿ô¤Î³Æ¥â¡¼¥É¤Ç¼Â¹Ô¤·¤¿¾ì¹ç¡¢x¤¬¾®¿ô¤Î¤È¤¤ÏÎã³°¤¬È¯À¸¤¹¤ë¡£
(2) PERM(n,r);COMB(n,r)¤ò2¿Ê¥â¡¼¥É,Ê£ÁÇ¿ô¥â¡¼¥É¤Ç¼Â¹Ô¤·¤¿¾ì¹ç¡¢r¤¬¾®¿ô¤Î¤È¤Îã³°¤È¤Ê¤é¤ºr¤òÀ°¿ô¤Ë´Ý¤á¤ÆÆÀ¤¿ÃͤòÊÖ¤¹¡£
400 OPTION ARITHMETIC NATIVE
410 LET n=6
420 FOR r=-2 TO 3.0001 STEP 0.1
430 WHEN EXCEPTION IN
440 PRINT n;r;" ---> ";PERM(n,r);COMB(n,r) ! r<-0.5¤Ç¤ÏÎã³°¤¬È¯À¸
450 USE
460 END WHEN
470 NEXT r
480 END
¾åµ¥×¥í¥°¥é¥à¤ò10¿Ê15·å,1000·å,ÍÍý¿ô¤Î³Æ¥â¡¼¥É¤Ç¼Â¹Ô¤·¤¿¾ì¹ç¡¢r¤¬¾®¿ô¤Î¤È¤¤ÏÎã³°¤¬È¯À¸¤¹¤ë¡£
(3) PERM(n,r),COMB(n,r)¤Çn¤¬Éé¿ô,¾®¿ô¤Î¤È¤Îã³°¤È¤Ê¤é¤º¸í¤Ã¤¿ÃͤòÊÖ¤¹¡£
600 LET r=3
610 FOR n=-4 TO 5 STEP 0.2
620 WHEN EXCEPTION IN
630 PRINT n;r;" ===> ";PERM(n,r);COMB(n,r)
640 USE
650 END WHEN
660 NEXT n
670 END
!¥¯¥ë¥¹¥«¥ë¡¦¥«¥¦¥ó¥È¡ÊKruskal count¡Ë
LET N=52 !¥«¡¼¥É¤ÎËç¿ô
LET mk$="SCHD" !¥«¡¼¥É¤Î¥Þ¡¼¥¯
LET nm$="A234567890JQK" !¥«¡¼¥É¤ÎÈÖ¹æ
DEF s2n(s)=MOD(s-1,13)+1 !Ï¢ÈÖ¤ò¥«¡¼¥É¤ÎÈÖ¹æ¤Ø
DEF s2m(s)=INT((s-1)/13)+1 !Ï¢ÈÖ¤ò¥«¡¼¥É¤Î¥Þ¡¼¥¯¤Ø
DIM c(N) !¥«¡¼¥É¤ÎʤÓ
SUB card_initialize(c(),N) !¥«¡¼¥É¤òÀ°Î󤹤ë
FOR i=1 TO N
LET c(i)=i
!!!PRINT i;s2m(i);s2n(i)
NEXT i
END SUB
RANDOMIZE
SUB shuffle_randomize(c(),N) !¥é¥ó¥À¥à¤Ë¥·¥ã¥Ã¥Õ¥ë¤¹¤ë
FOR i=N TO 2 STEP -1
LET j=INT(RND*(i-1))+1 !£±¡Ái-1
swap c(i),c(j)
NEXT i
END SUB
!------------------------------ ¤³¤³¤Þ¤Ç¤¬¥µ¥Ö¥ë¡¼¥Á¥ó
CALL card_initialize(c,N)
CALL shuffle_randomize(c,N)
MAT PRINT c;
FOR r=1 TO 10 !¹¥¤¤Ê¿ô»ú
LET p=r !¤½¤Î¿ô»ú¤ÎËç¿ôʬ¡¢¥È¥é¥ó¥×¤ò¾å¤«¤é½ç¤Ëɽ¸þ¤¤Ë¤·¤Æ´ù¤Î¾å¤Ë½Å¤Í¤ÆÇÛ¤ë¡Ê½çÈÖ¤òÊø¤µ¤Ê¤¤¤¿¤á¡Ë
DO WHILE p<=N !¼ê»ý¤Á¤Î¥È¥é¥ó¥×¤Î»Ä¤ê¤¬¤Ê¤±¤ì¤Ð¡¢½ªÎ»¡£
PRINT c(p); !ɽ¸þ¤¤Î°ìÈÖ¾å¤Î¥È¥é¥ó¥×¤Î¿ô»ú
LET t=s2n(c(p)) !£±¡Á£±£³
IF t>10 THEN LET t=5 !³¨»¥¤Ï¤¹¤Ù¤Æ£µ¤È¤¹¤ë
LET p=p+t !¼¡¤Ø
LOOP
PRINT
NEXT r !´ù¤Î¾å¤Îɽ¸þ¤¤Î¥È¥é¥ó¥×¤òÁ´¤Æ¼è¤ê¾å¤²¤Æ΢¸þ¤¤Ë¤·¡¢¼ê»ý¤Á¤Î¥È¥é¥ó¥×¤Î¾å¤ËÌ᤹
END
Full BASICµ¬³Ê¤Ï¡¤doʸ¤«loopʸ¤Î°ìÊý¤Ë¤·¤«¡Ö½Ð¸ý¾ò·ï¡×¤ò½ñ¤±¤Ê¤¤¤È¤¤¤¦¤è¤¦¤Êµ¬Äê¤ò´Þ¤ß¤Þ¤»¤ó¡£
¤Ê¤Î¤Ç¡¤doʸ¤Èloopʸ¤ÎξÊý¤ËWHILE¤Þ¤¿¤ÏUNTIL¤ò½ñ¤¤¤Æ¤âµ¬³Ê³°¤Î¥×¥í¥°¥é¥à¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£
¤Ä¤¤¤Ç¤Ë¸À¤¦¤È¡¤¤³¤ì¤Ë¤µ¤é¤ËEXIT DOʸ¤òÄɲ乤뤳¤È¤â¤Ç¤¤Þ¤¹¡£
!n=13¤Î¾ì¹ç
!0,1,2,3,4,5,6,7,8,9,10,11,12,13¤è¤ê¡¢¡Ö£±¡×¤Î¿ô¤Ï£¶¸Ä¤È¤Ê¤ë¡£
!¡èf(13)=6
OPTION ARITHMETIC NATIVE
LET fn=0 !£±¤Î¿ô
FOR n=0 TO 2^31-1 !ÈÏ°Ï
LET t=n !£°¡Á£î¤òɽ¸½¤¹¤ë
DO WHILE t>0 !³Æ·å¤¬£±¤Î¿ô¤ò¤«¤¾¤¨¤ë
IF MOD(t,10)=1 THEN LET fn=fn+1
LET t=INT(t/10)
LOOP
IF fn=n THEN PRINT "f(";n;")=";fn !f(n)=n¤Î¤Ê¤é
NEXT n
END
OPTION ARITHMETIC NATIVE
LET fn=0 !£±¤Î¿ô
FOR k=1 TO 12 !ÈÏ°Ï
LET n=10^k-1 !9,99,999,9999,¡Ä
PRINT "f(";n;")=";
FOR i=INT(n/10)+1 TO n !£°¡Á£î¤òɽ¸½¤¹¤ë
LET t=i !³Æ·å¤Î£±¤Î¿ô¤ò¤«¤¾¤¨¤ë
DO WHILE t>0
IF MOD(t,10)=1 THEN LET fn=fn+1
LET t=INT(t/10)
LOOP
NEXT i
PRINT fn !·ë²Ì¤òɽ¼¨¤¹¤ë
NEXT k
END
OPTION ARITHMETIC NATIVE
DECLARE FUNCTION change
DIM sum1(2 TO 10),max_n(2 TO 10)
MAT sum1=ZER
PRINT USING "##### ############(=>#########)":"p¿ÊË¡","f(n)=nºÇÂçÃÍ","10¿Ê¿ô"
FOR n=1 TO 7^7
FOR p=2 TO 7 ! p=8°Ê¾å¤Ï¸Ä¡¹¤Ë·×»»¤·¤Ê¤¤¤È»þ´Ö¤¬¤«¤«¤ë
LET x=n
DO
IF MOD(x,p)=1 THEN LET sum1(p)=sum1(p)+1
LET x=INT(x/p)
LOOP UNTIL x=0
IF sum1(p)=n THEN LET max_n(p)=n ! f(n)=n
NEXT p
NEXT n
FOR p=2 TO 10
PRINT USING " ## ########### (=##########)":p,change(max_n(p),p),max_n(p)
NEXT p
!
FUNCTION change(x,p) ! 10¿Ê¿ô¤òp¿Ê¿ô¤ËÊÑ´¹
LET s,k=0
DO
LET s=MOD(x,p)*10^k+s
LET k=k+1
LET x=INT(x/p)
LOOP UNTIL x=0
LET change=s
END FUNCTION
END
¥Ø¥ë¥×¤Î[Áàºî][¥ª¥×¥·¥ç¥ó¥á¥Ë¥å¡¼][¿ôÃÍ]¤Ë¤è¤ë¤È¡¢¼ÂºÝ¤Ë·×»»¤µ¤ì¤ë¿ôÃͤÈɽ¼¨¤µ¤ì¤ë¿ôÃͤÎÀºÅ٤˰㤤¤¬¤¢¤ë¤è¤¦¤Ç¤¹¡£
Î㣱¤Ç¤Ï¡¢2¿Ê¥â¡¼¥É¤Çx1¤Ï19·åÌÜ¤Þ¤Ç¤Ï 2.999999999999999555 ¤ÎÃͤò»ý¤Á¤Þ¤¹¤¬Ä̾ïɽ¼¨¤Ç¤Ï15·å¤Ë´Ý¤á¤é¤ì 3 ¤Èɽ¼¨¤µ¤ì¤Þ¤¹¡£
Î㣲Î㣳¤Ï¡Ö10¿Ê15·å¥â¡¼¥É¤Ç¤Ï¿ôÃͼ°¤È¤½¤ÎÃͤòÂåÆþ¤·¤¿ÊÑ¿ô¤È¤Ç¤ÏÀºÅÙ¤¬°Û¤Ê¤ë¡×¤³¤È¤Ëµ¯°ø¤¹¤ë¤È»×¤ï¤ì¤Þ¤¹¡£
¤¿¤È¤¨¤Ð¼¡¤Î¾®¥×¥í¥°¥é¥à¤Ç¤â¡¢10¿Ê¥â¡¼¥É¤Ç¤Ï a/7 ¤È b ¤Ï°Û¤Ê¤ëÃͤˤʤê¤Þ¤¹¡£
10 LET a=1
20 LET b=a/7
30 PRINT a/7 ; b
40 END
OPTION ARITHMETIC DECIMAL
!LET p=10 !Î㣱
!LET n=1000
!LET p=5 !Î㣲
!LET n=625
LET p=7 !Î㣳
LET n=49
LET x1=LOG(n)/LOG(p) !À°¿ôÉôʬ¤¬°Û¤Ê¤ë
LET x2=INT(LOG(n)/LOG(p)) !
PRINT "LOG(n)/LOG(p) =";LOG(n)/LOG(p)
PRINT "x1 =";x1
PRINT "INT(LOG(n)/LOG(p)) =";INT(LOG(n)/LOG(p))
PRINT "INT(x1) =";INT(x1)
PRINT "x2 =";x2
PRINT
CALL binary(STR$(p),STR$(n))
PRINT
CALL thousand(STR$(p),STR$(n))
END
EXTERNAL SUB binary(p$,n$)
OPTION ARITHMETIC NATIVE
LET p=VAL(p$)
LET n=VAL(n$)
LET x1=LOG(n)/LOG(p) !À°¿ôÉôʬ¤¬°Û¤Ê¤ë
LET x2=INT(LOG(n)/LOG(p)) !
PRINT "LOG(n)/LOG(p) =";LOG(n)/LOG(p)
PRINT "x1 =";x1
PRINT "INT(LOG(n)/LOG(p)) =";INT(LOG(n)/LOG(p))
PRINT "INT(x1) =";INT(x1)
PRINT "x2 =";x2
END SUB
EXTERNAL SUB thousand(p$,n$)
OPTION ARITHMETIC DECIMAL_HIGH
LET p=VAL(p$)
LET n=VAL(n$)
LET x1=LOG(n)/LOG(p) !À°¿ôÉôʬ¤¬°Û¤Ê¤ë
LET x2=INT(LOG(n)/LOG(p)) !
PRINT "LOG(n)/LOG(p) =";LOG(n)/LOG(p)
PRINT "x1 =";x1
PRINT "INT(LOG(n)/LOG(p)) =";INT(LOG(n)/LOG(p))
PRINT "INT(x1) =";INT(x1)
PRINT "x2 =";x2
END SUB
LET STR1$="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" !p¿ÊË¡¤Î¿ô»ú
FUNCTION ExBSTR$(n,p) !ÈóÉé¤ÎÀ°¿ôn¤òp¿ÊË¡¤Çɽµ¤¹¤ë
LET s$=""
DO
LET nn=INT(n/p)
LET t=n-nn*p !MOD(n,p)
LET s$=STR1$(t+1:t+1)&s$ !²¼¤Î°Ì¤«¤é
LET n=nn
LOOP UNTIL n=0
LET ExBSTR$=s$
END FUNCTION
LET p=5 !¿Ê¿ô
FOR n=1 TO p^p !¼«Á³¿ô
LET x=INT(LOG(n)/LOG(p))+1 !·å¿ô
LET x2=INT(LOG2(n)/LOG2(p))+1
LET x10=INT(LOG10(n)/LOG10(p))+1
LET k=g(n,p) !¿Ê¿ôÊÑ´¹¤Ë¤è¤ë
IF k<>x OR k<>x2 OR k<>x10 THEN PRINT n; STR$(p);"#";ExBSTR$(n,p), k; x; x2; x10
NEXT n
FUNCTION g(n,p) !¼«Á³¿ôn¤Îp¿ÊË¡¤Ç¤Î·å¿ô¡¡¢¨p^c=n
LET t=1
LET c=0 !·å¿ô
DO
LET t=t*p
LET c=c+1
LOOP WHILE t<=n
LET g=c
END FUNCTION
END
!Îã¡¡f(123)¤Î¾ì¹ç
!100¤È23¤Ëʬ²ò¤¹¤ë
!¡¡3·å¤Î¿ô¡ÊºÇ¾å°Ì·å=1¡Ë
!¡¡¡¡1xx·Á¼°¤Î¿ô = k·åÌܤË(23+1)=24¡¢(k-1)¡Á1·åÌܤËf(_99)=20
!¡¡Ã¼¿ô23
!¡¡¡¡f(23)
!¡¡¢Í
!¡¡¡¡20¤È3¤Ëʬ²ò¤¹¤ë
!¡¡¡¡¡¡2·å¤Î¿ô¡ÊºÇ¾å°Ì·å=2¡Ë
!¡¡¡¡¡¡¡¡1x·Á¼°¤Î¿ô = k·åÌܤË10^(2-1)=10¡¢(k-1)¡Á1·åÌܤËf(_9)=1
!¡¡¡¡¡¡¡¡2x·Á¼°¤Î¿ô = k¡Á1·åÌܤËf(_9)=1
!¡¡¡¡¡¡Ã¼¿ô3
!¡¡¡¡¡¡¡¡f(3)
!¡¡¡¡¡¡¢Í
!¡¡¡¡¡¡¡¡3¤È0¤Ëʬ²ò¤¹¤ë
!¡¡¡¡¡¡¡¡¡¡1·å¤Î¿ô¡ÊºÇ¾å°Ì·å=3¡Ë
!¡¡¡¡¡¡¡¡¡¡¡¡1·Á¼°¤Î¿ô = 1·åÌܤË10^(1-1)=1¡¢(1-1)·åÌܤËf(_)=0
!¡¡¡¡¡¡¡¡¡¡¡¡2·Á¼°¤Î¿ô = 1·åÌܤËf(_)=0
!¡¡¡¡¡¡¡¡¡¡¡¡3·Á¼°¤Î¿ô = 1·åÌܤËf(_)=0
!¡¡¡¡¡¡¡¡¡¡Ã¼¿ô0
!¡¡¡¡¡¡¡¡¡¡¡¡f(0)=0
!¡è(24+20) + (10+1 +1) + (1+0 +0 +0) +0 = 57
FUNCTION f(n$,p) !£°¡Á£î¤Þ¤Ç¤òÎ󵤷¤¿¤È¤¤Î¡Ö£±¡×¤Î¿ô¡¡¢¨n$¤ÏÈóÉé¤Îp¿ÊË¡¤Î¿ôÃÍ
local k,m,t$
IF ExBVAL(n$,p)=0 THEN
LET f=0
ELSE
LET k=LEN(n$) !·å¿ô
LET m=VAL1(n$(1:1)) !ºÇ¾å°Ì·å¤ËÃåÌܤ¹¤ë
LET t$=n$(2:LEN(n$)) !ü¿ô
!PRINT n;k;m;t$ !debug
IF m=1 THEN !(1xxx¡Äx)¤Î¾ì¹ç
LET w=ExBVAL(t$,p)+1
ELSE !(2xxx¡Äx)¡¢¡Ä¡¢(9xxx¡Äx)¤Î¾ì¹ç
LET w=p^(k-1)
END IF
LET f=( w + f(REPEAT$(STR1$(p:p),k-1),p)*m ) + f(t$,p) !k·å + f(ü¿ô)
END IF
END FUNCTION
LET STR1$="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" !p¿ÊË¡¤Î¿ô»ú
DEF VAL1(x$)=POS(STR1$,x$)-1
FUNCTION ExBVAL(n$,p) !n$¤òÈóÉé¤Îp¿ÊË¡¤Î¿ôÃͤȤ·¤¿ÃÍ
LET s=0
FOR i=1 TO LEN(n$)
LET s=s*p+VAL1(n$(i:i))
NEXT i
LET ExBVAL=s
END FUNCTION
FUNCTION ExBSTR$(n,p) !ÈóÉé¤ÎÀ°¿ôn¤òp¿ÊË¡¤Çɽµ¤¹¤ë
LET s$=""
DO
LET nn=INT(n/p)
LET t=n-nn*p !MOD(n,p)
LET s$=STR1$(t+1:t+1)&s$ !²¼¤Î°Ì¤«¤é
LET n=nn
LOOP UNTIL n=0
LET ExBSTR$=s$
END FUNCTION
!------------------------------ ¤³¤³¤Þ¤Ç¤¬¥µ¥Ö¥ë¡¼¥Á¥ó
PRINT f("1111111110",10) !10¿ÊË¡
PRINT ExBVAL("111110",6); f("111110",6) !£¶¿ÊË¡
LET p=4 !£´¿ÊË¡
FOR n=0 TO p^p
LET w$=ExBSTR$(n,p)
IF f(w$,p)=n THEN PRINT "f(";n;")=";n, STR$(p);"#";w$
NEXT n
END
!2¤«¤é30¤Þ¤Ç¤ÎÀ°¿ô¤Ç¤Ï¡¢
!¡¡2,3,4,5,5,7,6,6,7, 11,7,13,9,8,8,17,8,19,9, 10,13,23,9,10,15,9,11,29,10
!¤È¤Ê¤ë¡£
LET N=30 !£²¡Á£Î¤ÎÈÏ°Ï
DIM sf(N) !ÁÇ°ø¿ô¤ÎÏÂ
MAT sf=ZER
LET j=2 !ÁÇ°ø¿ô£²
DO WHILE j<=N
FOR i=j TO N STEP j !2,4,6,8,¡Ä¡¢4,8,12,16,¡Ä¡¢8,16,24,32,¡Ä¡¢¡Ä¡¡ÇÜ¿ô
LET sf(i)=sf(i)+2 !ÁÇ°ø¿ô¤ò²Ã»»¤·¤Æ¤¤¤¯
NEXT i
LET j=j*2 !2,4,8,16,¡Ä¡¡¤Ù¤¾è
LOOP
FOR k=3 TO N STEP 2 !£³°Ê¾å¤ÎÁÇ°ø¿ô
IF sf(k)=0 THEN !¡Ö¥¨¥é¥È¥¹¥Æ¥Í¥¹¤Î¤Õ¤ë¤¤¡×¤ÈƱ¤¸¤ÇÁÇ°ø¿ô¤È¤Ê¤ë
LET j=k
DO WHILE j<=N !¹â¡¹SQR(N)¤Þ¤Ç
FOR i=j TO N STEP j !j*m¡¢m=1,2,3,¡Ä
LET sf(i)=sf(i)+k
NEXT i
LET j=j*k !k^m¡¢m=1,2,3,¡Ä
LOOP
END IF
NEXT k
FOR i=2 TO N !·ë²Ì¤òɽ¼¨¤¹¤ë
PRINT i;":"; sf(i)
NEXT i
END
¡ü¡ÖÁÇ°ø¿ôʬ²ò¡Ê¼°¤òɽ¼¨¤¹¤ë¡Ë¡×¤ò²þ½¤¤¹¤ë¾ì¹ç
LET N=120 !Àµ¤ÎÀ°¿ô
LET s=0 !ÁÇ°ø¿ô¤ÎÏ <----- ÄɲÃ
PRINT N;":"; !<----- Êѹ¹
LET x=N
LET f=2 !³ä¤ë¿ô
DO WHILE x>=f*f !SQR(N)¡æf
LET xx=INT(x/f)
IF x-xx*f=0 THEN !³ä¤êÀÚ¤ì¤ì¤Ð
LET x=xx
PRINT f;"+"; !<----- Êѹ¹
LET s=s+f !<----- ÄɲÃ
ELSE !³ä¤êÀÚ¤ì¤Ê¤±¤ì¤Ð¡¢¼¡¤Ø
LET f=f+1
END IF
LOOP
PRINT x;
LET s=s+x !<----- ÄɲÃ
PRINT "="; s !·ë²Ì¤òɽ¼¨¤¹¤ë <----- ÄɲÃ
END
¿ôÃͤΠNOT AND OR ¡¢¸ìƬ 0x ¤Ç¤Î16¿Ê¿ôɽµ ¢ª personal extension ¤Î´õ˾¤Ç¤¹¡£
±ï¤Î²¼¤Î·×»»µ¡¤Ë¤Ï¡¢ºÇ½ªÅª¤ÊÌ¿Îá¤È¥Ç¡¼¥¿·Á¼°¡Ä ¤Î¤Ï¤º¤Ç¤¹¤¬¡¢
»ÈÍѤ·¤Ê¤¤¤è¤¦¤ËÅØÎϤ¹¤ëÊÊ ¤¬¤Ä¤¤¤Æ¡¢¿¶¤êÊÖ¤ë»þ¡¢³Ø½¬¥Æ¡¼¥Þ¤Ë À§¤«Èݤ«¡¢
¼«Ê¬¤Î¿Èʬ¤Ç¹Í¤¨¤ë»ö¤Ç¤Ï¤Ê¤¤¤±¤ì¤É¤â¡¢µ¿Ì䤫¤é¤ÎÄó°Æ¤Ç¤¹¡£
BASIC ¤À¤«¤é¡Ö¤³¤Î¤Þ¤Þ¤Ç¤¤¤¤¡×¤ÎÀ¼¤â¶¯¤¯Ê¹¤³¤¨¤ë¤¬¡¦¡¦¡¦
Windows¸ÂÄê¤Ç¤¹¤¬¡¤ http://hp.vector.co.jp/authors/VA008683/BitOp.htm
¤ò»È¤¨¤Ð¡¤
LET A = AND( B, BVAL("30",16) )
¤¢¤ë¤¤¤Ï¡¤
LET A = AND(B, BVAL"00110000",2))
¤È½ñ¤¯¤³¤È¤¬²Äǽ¤Ç¤¹¡£
¤³¤ì¤é¤Î´Ø¿ô¤ÏFull BASIC¤ÎÌ¿Îá¤À¤±¤ÇÄêµÁ¤¹¤ë¤³¤È¤â²Äǽ¤Ê¤Î¤Ç¡¤
¸ß´¹À¤ò»¤Ê¤¦¤³¤È¤Ï¤¢¤ê¤Þ¤»¤ó¡£
PRINT numb$("ONE+TWO+FOUR")
PRINT numb$("-One-Two-Three")
PRINT numb$("Two+Seven")
PRINT numb$(" - one + two - seven + ten ")
PRINT numb$("- one+ two- seven+ ten ")
PRINT numb$(" -one +two -seven +ten ")
FUNCTION numb$(w$)
LET n=0
LET i=1
DO WHILE i<=LEN(w$)
LET p$=""
DO WHILE w$(i:i)="+" OR w$(i:i)="-" OR w$(i:i)=" "
LET p$=p$& w$(i:i)
LET i=i+1
LOOP
LET n$=""
DO WHILE w$(i:i)<>"+" AND w$(i:i)<>"-" AND w$(i:i)<>" "
LET n$=n$& w$(i:i)
LET i=i+1
LOOP UNTIL LEN(w$)< i
LET j=num(n$)
IF POS(p$,"-")<>0 THEN LET j=-j
LET n=n+j
LOOP
IF n< 0 THEN LET p$="-" ELSE LET p$=""
LET numb$= p$& num$(ABS(n))
END FUNCTION
OPTION ARITHMETIC NATIVE
DIM n0(0 TO 9),nn(0 TO 9)
MAT READ n0
DATA 0,1,2,3,4,5,6,7,8,9
CALL perm(n0,0)
PRINT "½ªÎ»"
SUB perm(n0(),j)
local i
IF j<=9 THEN
FOR i=0 TO 9-j
LET nn(j)=n0(i)
swap n0(i),n0(9-j)
CALL perm(n0,j+1)
swap n0(i),n0(9-j)
NEXT i
ELSE
CALL check
END IF
END SUB
SUB check
!MAT PRINT USING REPEAT$("# ",10):nn
LET E=nn(0)
LET O=nn(1)
LET R=nn(2)
LET N=nn(3)
LET W=nn(4)
LET U=nn(5)
LET T=nn(6)
LET V=nn(7)
LET F=nn(8)
LET S=nn(9)
LET yy0= E+O+R
IF N= MOD( yy0,10) THEN
LET cy0= IP( yy0/10) !carry
!---
LET yy1= N+W+U +cy0
IF E=MOD( yy1,10) THEN
LET cy1= IP( yy1/10) !carry
!---
LET yy2= 2*O+T +cy1
IF V=MOD( yy2,10) THEN
LET cy2= IP( yy2/10) !carry
!---
LET yy3= F +cy2
IF E=MOD( yy3,10) AND S=IP( yy3/10) THEN
!---
PRINT " O N E"
PRINT " T W O"
PRINT " + F O U R"
PRINT "¨¡¨¡¨¡¨¡¨¡¨¡¨¡"
PRINT " S E V E N"
PRINT
PRINT " ";O ;N ;E
PRINT " ";T ;W ;O
PRINT " + ";F ;O ;U ;R
PRINT "¨¡¨¡¨¡¨¡¨¡¨¡¨¡"
PRINT S ;E ;V ;E ;N
PRINT
END IF
END IF
END IF
END IF
END SUB
1
ONE 350
TWO 673
¡Ü FOUR 9382
-------
SEVEN 10405
2
ONE 350
TWO 683
¡Ü FOUR 9372
-------
SEVEN 10405
3
ONE 530
TWO 625
¡Ü FOUR 9548
-------
SEVEN 10703
4
ONE 530
TWO 645
¡Ü FOUR 9528
-------
SEVEN 10703
5
ONE 630
TWO 526
¡Ü FOUR 9647
-------
SEVEN 10803
6
ONE 630
TWO 546
¡Ü FOUR 9627
-------
SEVEN 10803
7
ONE 940
TWO 729
¡Ü FOUR 8935
-------
SEVEN 10604
8
ONE 940
TWO 739
¡Ü FOUR 8925
-------
SEVEN 10604
¾¤ÎʤÌÌ»»¤Ë¤â±þÍѤǤ¤ë¤è¤¦¤Ë¤·¤Þ¤·¤¿¡£
¼¡¤Î3²Õ½ê¤òÊѹ¹¤¹¤ë¤À¤±¤Ç¼Â¹Ô¤Ç¤¤ë¤È»×¤¤¤Þ¤¹¡£
£±¡¥ÊÑ¿ô k ¤ÎÃÍ¡ÊLET k=4 ! ñ¸ì¤Î¸Ä¿ô¡Ë
£²¡¥³Æñ¸ì¤ÎDATA¡ÊDATA "ONE","TWO","FOUR","SEVEN"¡Ë
£³¡¥IFʸ¤ÇȽÄꤹ¤ë·×»»¼°
¡ÊIF h0=0 AND change("ONE")+change("TWO")+change("FOUR")=change("SEVEN") THEN¡Ë
SEND+MORE=MONEY ¤Ç»î¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
OPTION ARITHMETIC NATIVE
DECLARE EXTERNAL SUB perm,charac,headset
DECLARE EXTERNAL FUNCTION random
PUBLIC NUMERIC k,num(10),head(30),check(0 TO 9)
PUBLIC STRING word$(30),c$(10)
LET k=4 ! ñ¸ì¤Î¸Ä¿ô
!LET k=3
FOR i=1 TO k
READ word$(i)
NEXT i
DATA "ONE","TWO","FOUR","SEVEN"
!DATA "SEND","MORE","MONEY"
CALL charac(word$)
CALL headset
RANDOMIZE
MAT check=ZER
FOR i=1 TO 10
LET num(i)=random
NEXT i
!
CALL perm(num,1)
END
!
!
REM 1¡Án¤Î½çÎó¤ò¼½ñ¼°½ç½ø¤ÇÀ¸À®¤¹¤ë¡£
!½½¿ÊBASICźÉÕ"\BASICw32\SAMPLE\PERMUTAT.BAS"»²¾È
EXTERNAL SUB perm(a(),n)
OPTION ARITHMETIC NATIVE
DECLARE FUNCTION change
IF n=10 THEN
LET h0=0
FOR ii=1 TO k
IF num(head(ii))=0 THEN
LET h0=1 ! ÀèƬʸ»ú¤¬ 0
EXIT FOR
END IF
NEXT ii
IF h0=0 AND change("ONE")+change("TWO")+change("FOUR")=change("SEVEN") THEN
!IF h0=0 AND change("SEND")+change("MORE")=change("MONEY") THEN
FOR ii=1 TO k
PRINT word$(ii);" =";change(word$(ii))
NEXT ii
FOR ii=1 TO 10
PRINT c$(ii);"=";STR$(num(ii));" ";
NEXT ii
PRINT
STOP
END IF
ELSE
FOR i=n TO 10
LET t=a(i)
FOR j=i-1 TO n STEP -1
LET a(j+1)=a(j)
NEXT j
LET a(n)=t
CALL perm(a,n+1)
LET t=a(n)
FOR j=n TO i-1
LET a(j)=a(j+1)
NEXT j
LET a(i)=t
NEXT i
END IF
FUNCTION change(w$)
LET l=LEN(w$)
LET s=0
FOR i=1 TO l
FOR j=1 TO 10
IF c$(j)=w$(i:i) THEN
LET s=s+10^(l-i)*num(j)
EXIT FOR
END IF
NEXT j
NEXT i
LET change=s
END FUNCTION
END SUB
!
EXTERNAL SUB charac(a$())
OPTION ARITHMETIC NATIVE
LET s=SIZE(a$)
LET c=1
LET c$(1)=a$(1)(1:1)
FOR i=1 TO s
FOR j=1 TO LEN(a$(i))
LET cc=0
FOR kk=1 TO c
IF a$(i)(j:j)<>c$(kk) THEN LET cc=cc+1
NEXT kk
IF cc=c THEN
LET c=c+1
LET c$(c)=a$(i)(j:j)
IF c=10 THEN EXIT SUB
END IF
NEXT j
NEXT i
END SUB
!
EXTERNAL SUB headset
OPTION ARITHMETIC NATIVE
FOR i=1 TO k
FOR j=1 TO 10
IF word$(i)(1:1)=c$(j) THEN LET head(i)=j !ÀèƬʸ»ú
NEXT j
NEXT i
END SUB
!
EXTERNAL FUNCTION random
OPTION ARITHMETIC NATIVE
LET r=INT(10*RND)
IF check(r)=0 THEN
LET random=r
LET check(r)=1
ELSE
LET random=random
END IF
END FUNCTION
2¿Ê¥â¡¼¥É¤Ç¼¡¤Î¥×¥í¥°¥é¥à¤ò¼Â¹Ô¤¹¤ë¤ÈÊѤʸ½¾Ý¤¬µ¯¤³¤ê¤Þ¤¹¡£
2¿Ê¥â¡¼¥É¤Çʸ»úÎó½èÍý¤¹¤ë¿Í¤¬¤¤¤Ê¤«¤Ã¤¿¤Î¤¬¥Ð¥°È¯³Ð¤¬Ã٤줿¸¶°ø¤Ç¤·¤ç¤¦¤«¡£
OPTION ARITHMETIC NATIVE
DIM a$(4)
FOR i= 1 TO 4
PRINT a$(i)
NEXT i
END
ÀÜÅÀ¿ô¡¡¡¡£µ£µ£±£±¸Ä¤Î¡¡¡¡6ÁؤΡ¡¡¡¥Õ¥ì¡½¥à¤ò
»ä¤Î¡¡¥½¥Õ¥È¤Ç¡¡²ò¤¯¤È
full basic ¤Ç¡¡¡¡Ìó¡¡170»þ´Ö¡¡¡¡¤«¤«¤ê¤Þ¤¹
¤½¤ì¤ò
turbo C++ ¤Ç¤È¤¯¤È¡¡¡¡Ìó¡¡3»þ´Ö¤Î¡¡¡¡Í½Äê¤Ç¤¹
turbo C++ ¤Ç¡¡¡¡¹½Â¤²òÀÏͽÄê¤Î
6ÁØ¡¡¥Õ¥ì¡½¥à¤Î
turbo C++ ¤Ç¡¡¡¡ºîÀ½¤·¤¿
input data ¤ò
¿ô»ú¤Î¡¡¡¡´Ö¤Ë¡¡¡¡¥³¥ó¥Þ¡¡°õ¤ò¡¡¡¡Æþ¤ì¤ë¤À¤±¤Ç
´Êñ¤Ë
full basic ¤Ç¡¡¡¡computer graphic ¤¹¤ë¤³¤È¤Ë
À®¸ù¤·¤Þ¤·¤¿
¥Õ¥¡¥¤¥ë£±¡¡¡¡¤Ë¡¡¡¡ÅºÉÕ¤·¤Þ¤¹
turbo C++ ¤Ç¤Î¡¡¡¡computer grahic ¤Ï
Èó¾ï¤Ë¡¡¡¡Æñ¤·¤¯
Ť¤´Ö¡¡¡¡Çº¤ó¤Ç¤¤¤Þ¤·¤¿
turbo C++ ¤Ç¡¡¡¡6Áإե졽¥à¤ò¡¡¡¡²¼¤«¤é¡¡¡¡²¡¤·¾å¤²¤¿»þ¤Î
¾ò·ï¤Ç¡¡¡¡·×»»¤µ¤»
full basic ¤Ç¡¡¡¡6Áإե졽¥à¤Î¡¡¡¡°ú¤ÃÄ¥¤ê¡¡Éôʬ¤ò¡¡¡¡ÀÄ
°µ½ÌÉôʬ¤ò¡¡¡¡À֤ǡ¡¡¡¿§¤º¤±¡¡¡¡¤·¤Þ¤·¤¿
!ʤÌÌ»»¡ÊnPr½çÎó¡Ü»Þ¼í¤ê¡Ë
DECLARE EXTERNAL SUB F.perm !³°Éô¼ê³¤¡¢ÊÑ¿ô¤òÀë¸À¤¹¤ë
DECLARE EXTERNAL NUMERIC F.ANSWER_COUNT
LET t0=TIME
CALL perm(0, 1) !¥¥ã¥ê¡¼¤Ï£°¡¢°ì¤Î°Ì¤«¤é
IF ANSWER_COUNT=0 THEN PRINT "²ò¤Ê¤·"
PRINT "·×»»»þ´Ö=";TIME-t0
END
MODULE F
SHARE STRING c$
!¡¡ ONE ¢¢¨°ì¤Î°Ì¤«¤éa()¤Ë½ç¤Ë³ä¤êÉÕ¤±¤ë
! TWO ¢
!+ FOUR ¢
!------
! SEVEN ¢
LET c$="EORNWUTVFS" !°Û¤Ê¤ëʸ»ú¡¡¢«¢«¢«¢«¢«¡¡¢¨º¹¤·Âؤ¨
IF LEN(c$)>10 THEN
PRINT "»ØÄê¤Ç¤¤ëʸ»ú¤Ï£±£°Ê¸»ú°ÊÆâ¤Ç¤¹¡£"
STOP
END IF
SHARE NUMERIC a(10) !ʸ»ú¤ËÀßÄꤷ¤¿¿ôÃÍ¡Ê£°¡Á£¹¡Ë
MAT a=ZER(LEN(c$)) !ʸ»ú¿ô¤ÈƱ¿ô¤ËÄ´À°¤¹¤ë
SHARE NUMERIC f(0 TO 9) !ʸ»ú¤Ë³ä¤êÅö¤Æ¤ë¿ô¡Ê£°¡Á£¹¡Ë¥Õ¥é¥°ÍÑ¡¡¢¨
MAT f=ZER
PUBLIC NUMERIC ANSWER_COUNT !²òÅú¿ô
LET ANSWER_COUNT=0
EXTERNAL FUNCTION fnVAL(w$) !ʸ»úɽ¸½¤Î¿ô¤ò¿ôÃͤ˴¹¤¨¤ë
LET v=0
FOR i=1 TO LEN(w$)
LET p=POS(c$,w$(i:i))
LET v=v*10+a(p)
NEXT i
LET fnVAL=v
END FUNCTION
PUBLIC SUB perm
EXTERNAL SUB perm(cy, L) !nPr½çÎó¤Ç¤Î¿ô¤ÎÁȤòÀ¸À®¤¹¤ë
FOR nm=LBOUND(f) TO UBOUND(f) !½ÅÊ£¤òÈò¤±¤Æ¡¢£°¡Á£¹¤Î¿ô»ú¤ò³ä¤êÅö¤Æ¤ë
IF f(nm)=0 THEN
LET f(nm)=1 !»ÈÍÑÃæ¥Õ¥é¥°¤òON¤Ë¤¹¤ë
LET a(L)=nm !LÈÖÌܤò¿ônm¤È¤¹¤ë
!----- ¢¢¢¢¢ -----¡¡¢¨º¹¤·Âؤ¨
SELECT CASE c$(L:L)
CASE "N" !°ì¤Î°Ì¤ò³Îǧ¤¹¤ë
LET k=fnVAL("E")+fnVAL("O")+fnVAL("R")
IF MOD(k,10)=fnVAL("N") THEN
CALL perm(INT(k/10), L+1)
END IF
CASE "U" !½½¤Î°Ì¤ò³Îǧ¤¹¤ë
LET k=fnVAL("N")+fnVAL("W")+fnVAL("U") + cy
IF MOD(k,10)=fnVAL("E") THEN
CALL perm(INT(k/10), L+1)
END IF
CASE "V" !É´¤Î°Ì¤ò³Îǧ¤¹¤ë
LET k=fnVAL("O")+fnVAL("T")+fnVAL("O") + cy
IF fnVAL("O")>0 AND fnVAL("T")>0 AND MOD(k,10)=fnVAL("V") THEN
CALL perm(INT(k/10), L+1)
END IF
CASE "S" !Ëü¤ÈÀé¤Î°Ì¤ò³Îǧ¤¹¤ë
LET k=fnVAL("F") + cy
IF fnVAL("F")>0 AND fnVAL("S")>0 AND k=fnVAL("SE") THEN
LET ANSWER_COUNT=ANSWER_COUNT+1 !²òÅú¿ô
PRINT ANSWER_COUNT
PRINT USING " ONE ####":fnVAL("ONE") !·ë²Ì¤Îɽ¼¨
PRINT USING " TWO ####":fnVAL("TWO")
PRINT USING "¡Ü FOUR ####":fnVAL("FOUR")
PRINT "-------"
PRINT USING " SEVEN #####":fnVAL("SEVEN")
PRINT
!STOP !£±¤Ä¤À¤±¤Ê¤é¥³¥á¥ó¥È¤ò¤Ï¤º¤¹
END IF
CASE ELSE
IF L<LEN(c$) THEN CALL perm((cy), L+1) !¼¡¤Îʸ»ú¤Ø¡¡¢¨cy¤ÏÃÍÅϤ·
END SELECT
!----- ¢¬¢¬¢¬¢¬¢¬ -----
LET f(nm)=0 !̤»ÈÍÑ
END IF
NEXT nm
END SUB
END MODULE
Rolling Cube1
¤µ¤¤¤³¤í¤¬£¹¸Ä¡Ê£³¡ß£³¡ËÆþ¤ëÈ¢¤¬¤¢¤ê¡¢Ãæ±û¤Ë¤Ï¤µ¤¤¤³¤í¤¬¤Ê¤¯¡¢¼þ¤ê¤Ë£¸¸Ä¤Î¤µ¤¤¤³¤í¤¬£±¤ÎÌܤò²¼¤Ë¤·¤ÆÇÛÃÖ¤µ¤ì¤Æ¤¤¤ë¡£
¤µ¤¤¤³¤í¤ò¶õ¤ÃϤËž¤¬¤¹¤³¤È¤Ç¡¢Á´¤Æ¤Î¤µ¤¤¤³¤í¤ÎÌܤ¬£±¤¬½Ð¸½¤¹¤ë¤è¤¦¤Ë¤»¤è¡£
Rolling Cube2
8¡ß8¤Î¥ª¥»¥íÈĤκ¸¾å¤Ë£±¤ÎÌܤò¾å¤Ë¤·¤¿¤µ¤¤¤³¤í¤¬¤¢¤ë¡£Á´¤Æ¤Î¥Þ¥¹Ìܤò£±¤ÎÌܤ¬½Ð¸½¤·¤Ê¤¤¤è¤¦¡Ê¾å¤ÎÌ̤ˣ±¤ÎÌܤ¬½Ð¤Ê¤¤¡£¡Ë¤Ëž¤¬¤·¤Æ¤¤¤¡¢ºÇ¸å¤Ë±¦¾å¤Î¥Þ¥¹ÌܤǽªÎ»¤¹¤ë»þ½é¤á¤Æ£±¤ÎÌܤ¬¸½¤ì¤ë¤³¤È¡£
Rolling Cube2¤¬
LET s$="RRRDLDLULDDDDDDRURDRUULLUURDRUURDDRURDDLLDDRURDRUUUUUULDLULURRR"
¤Ç̵»öÅþÃ夷¤Þ¤·¤¿¡£
Ť¤¤â¤ä¤â¤ä¤¬¥¹¥Ã¥¥ê¤·¤¿µ¤Ê¬¤Ç¤¹¡£
¤½¤¦¤¤¤¨¤Ð¡¢°ÊÁ°¤³¤ó¤ÊÌäÂê¤ò»³Ã椵¤ó¤«¤é½ÐÂꤵ¤ì¤Æ¤¤¤Þ¤·¤¿¤Í¡£
¤¹¤Ã¤«¤ê˺¤ì¤Æ¤¤¤Þ¤·¤¿¡£¤³¤ó¤Ê¤È¤³¤í¤Ç·Ò¤¬¤ë¤È¤Ï»×¤Ã¤Æ¤â¤¤¤Þ¤»¤ó¤Ç¤·¤¿¡£
¶¯ÎÏ¤Ê¥×¥í¥°¥é¥àͤêÆñ¤¦¤´¤¶¤¤¤Þ¤·¤¿¡£
!¥Ñ¥º¥ë - ¾´ý¶ð¤ÎÆþ¤ìÂؤ¨
!£³¡ß£³¡¡£±¹ÔÌܤȣ³¹ÔÌܤòÆþ¤ìÂؤ¨¤ë
!¡¡¶ä¶â¶ä¡¡¡¡¡¡ÊâÊâÊâ
!¡¡³Ñ¡¡Èô¡¡¢ª¡¡³Ñ¡¡Èô
!¡¡ÊâÊâÊâ¡¡¡¡¡¡¶ä¶â¶ä
!Åú¤¨¡¡£³£°¼ê
LET t0=TIME
PUBLIC NUMERIC xSIZE,ySIZE !ÈפÎÂ礤µ
LET xSIZE=3
LET ySIZE=3
PUBLIC NUMERIC cSPACE !¶õÇò¤Î¿ô
LET cSPACE=1
DECLARE STRING INIT$ !½é´ü¤Î¾õÂÖ
LET INIT$="¶ä¶â¶ä³Ñ¡¡ÈôÊâÊâÊâ"
PUBLIC STRING GOAL$ !´°À®¤Î¾õÂÖ
LET GOAL$="ÊâÊâÊâ³Ñ¡¡Èô¶ä¶â¶ä" !´°Á´°ìÃ×
!!LET GOAL$="ÊâÊâÊâ¡û¡û¡û¡û¡û¡û" !Éôʬ°ìÃ×
PUBLIC STRING KO$(6) !¶ð¤Î¼ïÎà¤È°ÜÆ°²ÄǽÈÏ°Ï¡¡¢¨£¸¶á˵¡¡Æ°¤¤Ï¾´ý¤ÈƱ¤¸
DATA "¡ß¡û¡ß¡ßÊâ¡ß¡ß¡ß¡ß"
DATA "¡û¡û¡û¡ß¶ä¡ß¡û¡ß¡û"
DATA "¡û¡û¡û¡û¶â¡û¡ß¡û¡ß"
DATA "¡û¡ß¡û¡ß³Ñ¡ß¡û¡ß¡û"
DATA "¡ß¡û¡ß¡ûÈô¡û¡ß¡û¡ß"
DATA "¡û¡û¡û¡û¶Ì¡û¡û¡û¡û"
FOR i=1 TO 6
READ KO$(i)
NEXT i
PUBLIC NUMERIC LIM !¼ê¿ô¤Î¾å¸Â¡¡¢ªºÇ¾¯¼ê¿ô
LET LIM=200
PUBLIC STRING ANS$(0 TO 200) !¾å¸Â¤Þ¤Ç¤Î¼ê½ç
PUBLIC STRING STK$(0 TO 200) !¶ÉÌ̤εϿ¡¡¢¨¥¹¥¿¥Ã¥¯
FOR i=0 TO 200
LET ANS$(i)=""
LET STK$(i)=""
NEXT i
!PUBLIC NUMERIC LVL(0 TO 200) !----- trace -----
!MAT LVL=ZER
IF LEN(INIT$)<>ySIZE*xSIZE THEN
PRINT "ÈפÎÂ礤µ¡ÊxSIZE,ySIZE¡Ë¤È¶ð¤Î¿ô¡ÊINIT$¡Ë¤¬¹ç¤¤¤Þ¤»¤ó¡£"
STOP
END IF
IF LEN(GOAL$)<>ySIZE*xSIZE THEN
PRINT "ÈפÎÂ礤µ¡ÊxSIZE,ySIZE¡Ë¤È¶ð¤Î¿ô¡ÊGOAL$¡Ë¤¬¹ç¤¤¤Þ¤»¤ó¡£"
STOP
END IF
LET STK$(0)=INIT$
CALL backtrack(0) !£°¼êÌÜ
IF ANS$(0)="" THEN
PRINT "²ò¤Ê¤·"
ELSE
PRINT
FOR i=1 TO LIM !²ò¤òɽ¼¨¤¹¤ë
PRINT ANS$(i)
NEXT i
END IF
PRINT "·×»»»þ´Ö=";TIME-t0;"ÉÃ"
END
EXTERNAL SUB backtrack(L) !£±¼ê¤º¤ÄÂǤäƤ¤¤¡¢¹Ô¤µÍ¤Þ¤ì¤Ð¸µ¤ËÌá¤Ã¤Æ¤ä¤êľ¤¹
LET bd$=stk$(L) !¸½ºß¤Î¶ÉÌÌ
!---------- ¢¢¢¢¢ ---------- trace
!SET DRAW mode hidden !¤Á¤é¤Ä¤Ëɻߤγ«»Ï
!CLEAR
!FOR i=1 TO L
! PLOT TEXT ,AT 0.4+0.05*MOD(i-1,10),0.95-0.04*INT((i-1)/10): STR$(LVL(i))
!NEXT i
!FOR i=1 TO ySIZE
! LET t=(i-1)*xSIZE
! PLOT TEXT ,AT 0.1,0.50-i*0.05: bd$(t+1:t+xSIZE)
!NEXT i
!SET DRAW mode explicit !¤Á¤é¤Ä¤ËɻߤνªÎ»
!---------- ¢¬¢¬¢¬¢¬¢¬ ----------
LET C=0 !»Þ´¢¤ê¡¡¢¨¡Ö»Ä¤ê¤Î¼ê¿ô¡×¤È¡Ö¶ð¤Î°ÌÃÖ¤¬°ìÃפ·¤Ê¤¤¿ô¡×¤È¤Î´Ø·¸¤è¤ê
FOR i=1 TO ySIZE*xSIZE
SELECT CASE GOAL$(i:i)
CASE "¡ß","¡¡","¡û" !²¿¤Ç¤âÎɤ¤
CASE ELSE !´°Á´°ìÃ×
IF GOAL$(i:i)<>bd$(i:i) THEN LET C=C+1 !£Ã¸Ä¤Î¶ð¤ò°ìÃפµ¤»¤ëɬÍפ¬¤¢¤ë¤¬¡¢
END SELECT
NEXT i
IF L+C>LIM THEN EXIT SUB !»Ä¤ê¤Î¼ê¿ô¤¬Â¤ê¤Ê¤¤¤Î¤Ç¡¢ÉÔ²Äǽ¡ª¡ª¡ª
IF C=0 THEN !´°À®¤Ê¤é¡¢¼ê½ç¤òµÏ¿¤·¤Æ¤ª¤¯
PRINT L;"¼ê"
FOR i=0 TO L
LET ANS$(i)=STK$(i)
NEXT i
PRINT STK$(L) !debug
LET LIM=L !¾å¸Â¤ò¶¹¤á¤ë
END IF
IF L>=LIM THEN EXIT SUB !¾å¸Â¤Þ¤Ç
LET CntOfSP=0
FOR p=1 TO ySIZE*xSIZE !ÈפòÁöºº¤·¤Æ¶õÇò¤Ë¶ð¤ò°ÜÆ°¤µ¤»¤ë
IF bd$(p:p)="¡¡" THEN
LET px=MOD(p-1,xSIZE)+1 !¿åÊ¿¡¦¿âľ¤ÎºÂɸ¤Ø
LET py=INT((p-1)/xSIZE)+1
!!!FOR d=1 TO 9 !ÎÙÀܤ¹¤ë¶ð¤òõ¤¹¡¡¢¨¥±¡¼¥¹¥Ð¥¤¥±¡¼¥¹
FOR d=9 TO 1 STEP -1 !ÎÙÀܤ¹¤ë¶ð¤òõ¤¹¡¡¢¨¥±¡¼¥¹¥Ð¥¤¥±¡¼¥¹
IF d=5 THEN
ELSE
LET mx=px + MOD(d-1,3)-1 !°ÜÆ°¸µ¤ÎºÂɸ¡¡¢¨d¤ò¿åÊ¿¡¦¿âľ¤Îº¹Ê¬dx,dy¤Ø
LET my=py + INT((d-1)/3)-1
IF (mx>=1 AND mx<=xSIZE) AND (my>=1 AND my<=ySIZE) THEN !È×Æ⤫³Îǧ¤¹¤ë
LET mp=(my-1)*xSIZE + mx !Ï¢ÈÖ¤Ø
LET t$=bd$(mp:mp)
IF t$="¡ß" OR t$="¡¡" THEN
ELSE
FOR a=1 TO UBOUND(KO$) !¶ð¤Î°À¤òÆÀ¤ë
IF t$=KO$(a)(5:5) THEN EXIT FOR
NEXT a
IF KO$(a)(10-d:10-d)="¡ß" THEN !°ÜÆ°²ÄǽÈϰϤʤé
ELSE
LET w$=bd$
LET w$(p:p)=KO$(a)(5:5) !°ÜÆ°¤µ¤»¤ë
LET w$(mp:mp)="¡¡"
FOR t=L TO 0 STEP -1 !ºÇ¶á¤Î¶ÉÌ̤«¤é½ç¤Ë¿·¤·¤¤¼ê¤«¤É¤¦¤«³Îǧ¤¹¤ë
IF STK$(t)=w$ THEN EXIT FOR
NEXT t
IF t<0 THEN
!LET LVL(L+1)=CntOfSP*10+d !----- trace -----
LET STK$(L+1)=w$ !µÏ¿¤·¤Æ¡¢¼¡¤Î¶ÉÌ̤Ø
CALL backtrack(L+1)
END IF
END IF
END IF
END IF
END IF
NEXT d
LET CntOfSP=CntOfSP+1
IF CntOfSP=cSPACE THEN EXIT FOR !¶õÇò¤Î¿ô¤À¤±
END IF
NEXT p
END SUB
!¡üÌäÂê
!£¸¸Ä¤Î¤µ¤¤¤³¤í¤¬¡¢£³¡ß£³¤ÎÈפˣ±¤ÎÌܤò¾å¤Ë¤·¤Æ¾¤ÎÌܤâƱ¤¸¸þ¤¤ÇÇÛÃÖ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
!¶õ¤¤¤Æ¤¤¤ë¥Þ¥¹¤Ëž¤¬¤·¤Æ¡¢¤¹¤Ù¤Æ¤ÎÌܤ¬£¶¤Ë¤Ê¤ë¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£
!ÃÖ´¹¡ÊPermutation¡Ë¤Î·×»»
SUB PermPrintOut(A()) !ɽ¼¨¤¹¤ë
MAT PRINT USING(REPEAT$(" ##",UBOUND(A))): A;
PRINT
END SUB
SUB PermIdentity(A()) !¹±ÅùÃÖ´¹
FOR i=1 TO UBOUND(A)
LET A(i)=i
NEXT i
END SUB
SUB PermInverse(A(), iA()) !µÕÃÖ´¹¡¡¢¨iA¤ÏA°Ê³°¤ÎÇÛÎó¤ò»ØÄꤹ¤ë¤³¤È
FOR i=1 TO UBOUND(A)
LET iA(A(i))=i
NEXT i
END SUB
SUB PermMultiply(A(),B(), AB()) !ÀÑAB¡¡¢¨AB¤ÏA¤«¤ÄB°Ê³°¤ÎÇÛÎó¤ò»ØÄꤹ¤ë¤³¤È
FOR i=1 TO UBOUND(A)
LET AB(i)=A(B(i)) !¢¨¹çÀ®¼ÌÁü(AB)(i)=A(B(i))
NEXT i
END SUB
!-------------------- ¤³¤³¤Þ¤Ç¤¬¥µ¥Ö¥ë¡¼¥Á¥ó
DIM U(6),D(6),L(6),R(6) !ÃÖ´¹
! 1,2,3,4,5,6
DATA 3,2,6,4,1,5 !¾å¡¡¢¨ÀµÌ̤ò¾åÌ̤ˤ¹¤ë¤Î¡Ê¿Þ¤Ç¤Î¿åÊ¿¼´¡Ë²óž
!!!DATA 5,2,1,4,6,3 !²¼
DATA 1,3,4,5,2,6 !º¸
!!!DATA 1,5,2,3,4,6 !±¦
MAT READ U
CALL PermInverse(U,D)
!!!MAT READ D
MAT READ L
CALL PermInverse(L,R)
!!!MAT READ R
!---------- ¢¬¢¬¢¬¢¬¢¬ ----------
!Ÿ³«¿Þ¤ÎÇÛÃÖ¤ÈÌÌÈÖ¹æ¡ÊÇÛÎó¤Îź¤¨»ú¡Ë¤È¤Î´Ø·¸
!¡¡¢¢¡¡¡¡¡¡¡¡¸å¡¡¡¡¡¡¡¡£±
!¢¢¢¢¢¢¢¢¡¡º¸¾å±¦²¼¡¡£²£³£´£µ
!¡¡¢¢¡¡¡¡¡¡¡¡Àµ¡¡¡¡¡¡¡¡£¶
DIM T1(6),T2(6),T3(6),T4(6),T5(6),T6(6),T7(6),T8(6) !£¸¸Ä¤Î¤µ¤¤¤³¤í
DATA 5,4,1,3,6,2 !ÌܤÎÇÛÃÖ¡¡¢¨Å¸³«¿Þ»²¾È
MAT READ T1
MAT T2=T1 !Ʊ¤¸¸þ¤
MAT T3=T1
MAT T4=T1
MAT T5=T1
MAT T6=T1
MAT T7=T1
MAT T8=T1
PICTURE dice(T()) !¤µ¤¤¤³¤í¤òɽ¼¨¤¹¤ë¡¡¢¨¸¶ÅÀ´ð½à
SET TEXT JUSTIFY "CENTER","HALF"
PLOT TEXT ,AT 0,-0.4: STR$(T(1)) !¦Ì̤ÎÌܤοô
PLOT TEXT ,AT -0.4,0: STR$(T(2))
PLOT TEXT ,AT 0.4,0: STR$(T(4))
PLOT TEXT ,AT 0,0.4: STR$(T(6))
LET nm=T(3) !¾åÌ̤ÎÌܤοô
IF nm=1 THEN DRAW eye(4) !Ãæ±û
IF nm=3 OR nm=5 THEN DRAW eye(1)
IF nm=2 OR nm=4 OR nm=5 OR nm=6 THEN !º¸¼Ð¤á
DRAW eye(1) WITH SHIFT(0.25,0.25)
DRAW eye(1) WITH SHIFT(-0.25,-0.25)
END IF
IF nm=3 OR nm=4 OR nm=5 OR nm=6 THEN !±¦¼Ð¤á
DRAW eye(1) WITH SHIFT(0.25,-0.25)
DRAW eye(1) WITH SHIFT(-0.25,0.25)
END IF
IF nm=6 THEN !ÃæÃÊ
DRAW eye(1) WITH SHIFT(0.25,0)
DRAW eye(1) WITH SHIFT(-0.25,0)
END IF
END PICTURE
PICTURE eye(c) !£±¤Ä¤ÎÌܤòɽ¼¨¤¹¤ë
SET AREA COLOR c
DRAW disk WITH SCALE(0.1) !¢¨Í×Ä´À°
END PICTURE
!---------- ¢¬¢¬¢¬¢¬¢¬ ----------
LET MY=3 !¥Þ¥Ã¥×¤ÎÂ礤µ
LET MX=3
DIM M(MY,MX) !¤µ¤¤¤³¤í¤ÎÇÛÃÖ¡¡¢¨¿ô»ú¤ÏÈֹ桢£°¤Ï¶õ¤
DATA 1,2,3
DATA 4,0,5
DATA 6,7,8
MAT READ M
SUB dispMap !¥Þ¥Ã¥×¾å¤Î¤µ¤¤¤³¤í¤òɽ¼¨¤¹¤ë
FOR y=1 TO 3 !º¸¾å¤«¤é½ç¤Ë
LET yy=y-0.5 !°ÌÃÖ¤ò»»½Ð¤¹¤ë
FOR x=1 TO 3
LET xx=x-0.5
SELECT CASE M(y,x) !ÇÛÃÖ¤µ¤ì¤¿¤µ¤¤¤³¤í¤Ë±þ¤¸¤Æ
CASE 1
DRAW dice(T1) WITH SHIFT(xx,yy) !¾åÌÌ
CASE 2
DRAW dice(T2) WITH SHIFT(xx,yy)
CASE 3
DRAW dice(T3) WITH SHIFT(xx,yy)
CASE 4
DRAW dice(T4) WITH SHIFT(xx,yy)
CASE 5
DRAW dice(T5) WITH SHIFT(xx,yy)
CASE 6
DRAW dice(T6) WITH SHIFT(xx,yy)
CASE 7
DRAW dice(T7) WITH SHIFT(xx,yy)
CASE 8
DRAW dice(T8) WITH SHIFT(xx,yy)
CASE ELSE
END SELECT
NEXT x
NEXT y
END SUB
!---------- ¢¬¢¬¢¬¢¬¢¬ ----------
SUB move(T(),OP(),x,y,dx,dy) !¤µ¤¤¤³¤í¤ò²óž°ÜÆ°¤µ¤»¤ë
LET ANSWER_COUNT=ANSWER_COUNT+1
PRINT ANSWER_COUNT;"¼ê"
DIM TT(6) !ºî¶ÈÇÛÎó
CALL PermMultiply(T,OP,TT) !²óž
MAT T=TT
LET w=M(y,x) !°ÜÆ°
LET M(y,x)=M(y+dy,x+dx)
LET M(y+dy,x+dx)=w
END SUB
SUB CalcDirection(x,y, T()) !°ÜÆ°²Äǽ¤ÊÊý¸þ¤Ø²óž°ÜÆ°¤µ¤»¤ë
IF y>=2 THEN !¾å¤Ë°ÜÆ°²Äǽ¤Ç
IF M(y-1,x)=0 THEN !¶õ¤¥Þ¥¹¤Ê¤é
CALL move(T,U,x,y,0,-1) !²óž°ÜÆ°¤µ¤»¤ë
PRINT "UP";y;x
END IF
END IF
IF y<=2 THEN !²¼
IF M(y+1,x)=0 THEN
CALL move(T,D,x,y,0,1)
PRINT "DOWN";y;x
END IF
END IF
IF x>=2 THEN !º¸
IF M(y,x-1)=0 THEN
CALL move(T,L,x,y,-1,0)
PRINT "LEFT";y;x
END IF
END IF
IF x<=2 THEN !±¦
IF M(y,x+1)=0 THEN
CALL move(T,R,x,y,1,0)
PRINT "RIGHT";y;x
END IF
END IF
MAT PRINT M; !debug
END SUB
LET ANSWER_COUNT=0 !¼ê¿ô
SET WINDOW -1,MX+1,MY+1,-1 !ɽ¼¨Îΰè
LET cx=1 !¥Ý¥¤¥ó¥¿¤òº¸¾å¤Ë°ÌÃÖÉÕ¤±¤ë
LET cy=1
DO
mouse poll x,y,left,right !¥Þ¥¦¥¹¤Î¾ðÊó¤òÆÀ¤ë
LET xx=INT(x) !°ÌÃÖ
LET yy=INT(y)
IF xx>=0 AND xx<MX AND yy>=0 AND yy<MY THEN !¥Þ¥Ã¥×Æâ¤Ê¤é
LET cx=xx+1 ![1,MX]
LET cy=yy+1 ![1,MY]
END IF
IF left=1 THEN !º¸¥Ü¥¿¥ó¤¬²¡¤µ¤ì¤¿¤é
SELECT CASE M(cy,cx) !¤µ¤¤¤³¤í¤ÎÈÖ¹æ¤òÆÀ¤ë
CASE 1
CALL CalcDirection(cx,cy, T1) !²óž°ÜÆ°¤µ¤»¤ë
CASE 2
CALL CalcDirection(cx,cy, T2)
CASE 3
CALL CalcDirection(cx,cy, T3)
CASE 4
CALL CalcDirection(cx,cy, T4)
CASE 5
CALL CalcDirection(cx,cy, T5)
CASE 6
CALL CalcDirection(cx,cy, T6)
CASE 7
CALL CalcDirection(cx,cy, T7)
CASE 8
CALL CalcDirection(cx,cy, T8)
CASE ELSE
END SELECT
WAIT DELAY 0.2 !¢¨Í×Ä´À°
END IF
SET DRAW mode hidden !¤Á¤é¤Ä¤Ëɻ߳«»Ï
CLEAR
DRAW grid !ÌÜÀ¹¤ê
SET LINE width 2 !¥Ý¥¤¥ó¥¿¤òɽ¼¨¤¹¤ë
PLOT LINES: cx-1,cy-1; cx,cy-1; cx,cy; cx-1,cy; cx-1,cy-1
SET LINE width 1
CALL dispMap !¤µ¤¤¤³¤í¤òɽ¼¨¤¹¤ë
SET TEXT JUSTIFY "LEFT","BOTTOM" !ʸ»ú°ÌÃÖ¤ÎÄ´À°
PLOT TEXT ,AT -0.5,-0.5: "°ÜÆ°¤¹¤ë¤µ¤¤¤³¤í¤òº¸¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£"
SET DRAW mode explicit !¤Á¤é¤Ä¤Ëɻ߽ªÎ»
LOOP
END
!Åú¤¨¡¡£³£¸¼ê
!¡¡URDL,DRUL,LDRR,UULD,RUL;LDR,ULDD,RRUL,LDRU,LURD
PUBLIC NUMERIC FLG
LET X=8.99999999865/1.999999991572
PRINT "½¤ÀµÁ°";X;"½¤Àµ¸å";NUM(X);"ÍýÁÛÃÍ";9/2
LET X=7.000000000357/3.000000001345*5.99999999993247
PRINT "½¤ÀµÁ°";X;"½¤Àµ¸å";NUM(X);"ÍýÁÛÃÍ";14
LET X=-15/6.00000000352*10.000000034/2.999999999247
PRINT "½¤ÀµÁ°";X;"½¤Àµ¸å";NUM(X);"ÍýÁÛÃÍ";-25/3
LET X=SQR(2.500000000354)*SQR(2.9999999999999871)
PRINT "½¤ÀµÁ°";X;"½¤Àµ¸å";NUM(X);"ÍýÁÛÃÍ";SQR(7.5)
LET X=EXP(1.50000000321)*EXP(3.9999999999992417)
PRINT "½¤ÀµÁ°";X;"½¤Àµ¸å";NUM(X);"ÍýÁÛÃÍ";EXP(5.5)
END
EXTERNAL FUNCTION INTNUM(X)
LET EPS=1E-5 !'(Í×)Ä´À°
FOR I=0 TO 4 !'(Í×)Ä´À°
FOR J=0 TO 1
LET Y=ABS(X)*10^I+J*EPS
IF ABS(Y)-INT(ABS(Y))<=EPS THEN
LET INTNUM=SGN(X)*INT(ABS(Y))/10^I
LET FLG=1
EXIT FUNCTION
END IF
NEXT J
NEXT I
LET INTNUM=X
LET FLG=0
END FUNCTION
EXTERNAL FUNCTION NUM(X)
LET Y=INT(ABS(X))
LET P=ABS(X)-Y
LET K=INTNUM(X)
IF FLG=1 THEN
LET NUM=K
EXIT FUNCTION
END IF
LET K=INTNUM(1/P)
IF FLG=1 THEN
LET NUM=(Y+1/K)*SGN(X)
EXIT FUNCTION
END IF
LET K=INTNUM(X*X)
IF FLG=1 THEN
LET NUM=SQR(K)*SGN(X)
EXIT FUNCTION
END IF
IF X>0 THEN
LET K=INTNUM(LOG(X))
IF FLG=1 THEN
LET NUM=EXP(K)
EXIT FUNCTION
END IF
END IF
IF ABS(X)<228 THEN
LET K=INTNUM(EXP(X))
IF FLG=1 THEN
LET NUM=LOG(K)*SGN(X)
EXIT FUNCTION
END IF
END IF
LET NUM=X
END FUNCTION
OPTION ARITHMETIC COMPLEX
LET X=COMPLEX(1,-2)
LET N=5
DIM A(N)
PRINT "X=";X;"(";REAL(X);IMAG(X);")"
PRINT "SIN=";CSIN(X);CSIN2(X)
PRINT "COS=";CCOS(X);CCOS2(X)
PRINT "TAN=";CTAN(X);CTAN2(X)
PRINT "COSEC=";CCOSEC(X);CCOSEC2(X)
PRINT "SEC=";CSEC(X);CSEC2(X)
PRINT "COTAN=";CCOTAN(X);CCOTAN2(X)
PRINT "SINH=";CSINH(X);CSINH2(X)
PRINT "COSH=";CCOSH(X);CCOSH2(X)
PRINT "TANH=";CTANH(X);CTANH2(X)
PRINT "COSECH=";CCOSECH(X);CCOSECH2(X)
PRINT "SECH=";CSECH(X);CSECH2(X)
PRINT "COTANH=";CCOTANH(X);CCOTANH2(X)
PRINT "Ê¿Êýº¬=";CSQR(X);CEXP(CLOG(X)/2)
CALL CNPOW(X,N,A)
PRINT N;"¾èº¬"
FOR I=1 TO N
PRINT I;":";A(I);A(I)^N
NEXT I
LET Y=COMPLEX(1,2)
PRINT "X^Y=";CPOW(X,Y);CEXP(Y*CLOG(X))
END
! »°³Ñ´Ø¿ô
EXTERNAL FUNCTION CSIN(Z) !'sine
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET XR = SIN(X) * COSH(Y)
LET XI = COS(X) * SINH(Y)
LET CSIN=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CSIN2(Z)
OPTION ARITHMETIC COMPLEX
LET I=SQR(-1)
LET CSIN2=(CEXP(I*Z)-CEXP(-I*Z))/(2*I)
END FUNCTION
EXTERNAL FUNCTION CCOS(Z) !'cosine
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET XR = COS(X) * COSH(Y)
LET XI = -SIN(X) * SINH(Y)
LET CCOS=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CCOS2(Z)
OPTION ARITHMETIC COMPLEX
LET I=SQR(-1)
LET CCOS2=(CEXP(I*Z)+CEXP(-I*Z))/2
END FUNCTION
EXTERNAL FUNCTION CTAN(Z) !'tangent
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET D = COS(2 * X) + COSH(2 * Y)
LET XR = SIN(2 * X) / D
LET XI = SINH(2 * Y) / D
LET CTAN=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CTAN2(Z)
OPTION ARITHMETIC COMPLEX
LET CTAN2=CSIN(Z)/CCOS(Z)
END FUNCTION
EXTERNAL FUNCTION CCOSEC(Z) !'cosecant
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET D=COS(X)^2*SINH(Y)^2+SIN(X)^2*COSH(Y)^2
LET XR=SIN(X)*COSH(Y)/D
LET XI=-COS(X)*SINH(Y)/D
LET CCOSEC=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CCOSEC2(Z)
OPTION ARITHMETIC COMPLEX
LET CCOSEC2=1/CSIN(Z)
END FUNCTION
EXTERNAL FUNCTION CSEC(Z) !'secant
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET D=SIN(X)^2*SINH(Y)^2+COS(X)^2*COSH(Y)^2
LET XR=COS(X)*COSH(Y)/D
LET XI=SIN(X)*SINH(Y)/D
LET CSEC=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CSEC2(Z)
OPTION ARITHMETIC COMPLEX
LET CSEC2=1/CCOS(Z)
END FUNCTION
EXTERNAL FUNCTION CCOTAN(Z) !'cotangent
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET D=COSH(2*Y)+COS(2*X)
LET DD=SINH(2*Y)^2+SIN(2*X)^2
LET XR=SIN(2*X)*D/DD
LET XI=-SINH(2*Y)*D/DD
LET CCOTAN=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CCOTAN2(Z)
OPTION ARITHMETIC COMPLEX
LET CCOTAN2=1/CTAN(Z)
END FUNCTION
! µÕ»°³Ñ´Ø¿ô
EXTERNAL FUNCTION CASIN(Z) !'arcsine
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET D=SQR((Y^2-X^2+1)^2+4*X^2*Y^2)
LET S=SQR(D-Y^2+X^2-1)/SQR(2)
LET SS=SQR(D+Y^2-X^2+1)/SQR(2)
IF X*Y>0 THEN
LET XR=-ATAN2(S-X,SS-Y)
LET XI=-LOG((SS-Y)^2+(X-S)^2)/2
ELSE
LET XR=ATAN2(S+X,SS-Y)
LET XI=-LOG((SS-Y)^2+(X+S)^2)/2
END IF
LET CASIN=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CASIN2(Z)
OPTION ARITHMETIC COMPLEX
LET CASIN2=CATAN(Z/CSQR(1-Z*Z))
END FUNCTION
EXTERNAL FUNCTION CASIN3(Z)
OPTION ARITHMETIC COMPLEX
LET I=SQR(-1)
LET CASIN3=-I*CLOG(CSQR(1-Z*Z)+Z*I)
END FUNCTION
EXTERNAL FUNCTION CACOS(Z) !'arccosine
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET D=SQR((Y^2-X^2+1)^2+4*X^2*Y^2)
LET S=SQR(D+Y^2-X^2+1)/SQR(2)
LET SS=SQR(D-Y^2+X^2-1)/SQR(2)
IF X*Y>0 THEN
LET XR=ATAN2(S+Y,X+SS)
LET XI=-LOG((S+Y)^2+(SS+X)^2)/2
ELSE
LET XR=ATAN2(S+Y,X-SS)
LET XI=-LOG((S+Y)^2+(X-SS)^2)/2
END IF
LET CACOS=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CACOS2(Z)
OPTION ARITHMETIC COMPLEX
LET I=SQR(-1)
LET CACOS2=-I*CLOG(Z+I*CSQR(1-Z*Z))
END FUNCTION
EXTERNAL FUNCTION CATAN(Z) !'arctangent
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET XR=(ATAN2(X,Y+1)+ATAN2(X,1-Y))/2
LET XI=-LOG((1-Y)^2+X^2)/4+LOG((Y+1)^2+X^2)/4
LET CATAN=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CATAN2(Z)
OPTION ARITHMETIC COMPLEX
LET I=SQR(-1)
LET CATAN2=I/2*CLOG((I+Z)/(I-Z))
END FUNCTION
EXTERNAL FUNCTION CACOSEC(Z) !'arccosecant
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET S=X^2-Y^2
LET SS=4*X^2*Y^2
LET D=S^2+SS
LET E=S/D
LET DD=SS/D^2
LET EE=Y^2/D-X^2/D+1
IF X*Y>=0 THEN
LET XR= ATAN2(SQR(SQR((1-E)^2+DD)+E-1)/SQR(2)+X/(X^2+Y^2),SQR(SQR((1-E)^2+DD)-E+1)/SQR(2)+Y/(X^2+Y^2))
LET XI=-LOG((SQR(SQR(EE^2+DD)+EE)/SQR(2)+Y/(Y^2+X^2))^2+(X/(X^2+Y^2)+SQR(SQR(EE^2+DD)-EE)/SQR(2))^2)/2
ELSE
LET XR=-ATAN2(SQR(SQR((1-E)^2+DD)+E-1)/SQR(2)-X/(X^2+Y^2),SQR(SQR((1-E)^2+DD)-E+1)/SQR(2)+Y/(X^2+Y^2))
LET XI=-LOG((SQR(SQR(EE^2+DD)+EE)/SQR(2)+Y/(Y^2+X^2))^2+(X/(X^2+Y^2)-SQR(SQR(EE^2+DD)-EE)/SQR(2))^2)/2
END IF
LET CACOSEC=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CACOSEC2(Z)
OPTION ARITHMETIC COMPLEX
LET CACOSEC2=CASIN(1/Z)
END FUNCTION
EXTERNAL FUNCTION CACOSEC3(Z)
OPTION ARITHMETIC COMPLEX
LET CACOSEC3=CATAN(1/CSQR(Z*Z-1))
END FUNCTION
EXTERNAL FUNCTION CASEC(Z) !'arcsecant
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET S=X^2-Y^2
LET SS=4*X^2*Y^2
LET D=S^2+SS
LET E=S/D
LET DD=SS/D^2
LET EE=Y^2/D-X^2/D+1
IF X*Y>=0 THEN
LET XR=ATAN2(SQR(SQR((1-E)^2+DD)-E+1)/SQR(2)-Y/(X^2+Y^2),X/(X^2+Y^2)-SQR(SQR((1-E)^2+DD)+E-1)/SQR(2))
LET XI=-LOG((SQR(SQR(EE^2+DD)+EE)/SQR(2)-Y/(Y^2+X^2))^2+(X/(X^2+Y^2)-SQR(SQR(EE^2+DD)-EE)/SQR(2))^2)/2
ELSE
LET XR=ATAN2(SQR(SQR((1-E)^2+DD)-E+1)/SQR(2)-Y/(X^2+Y^2),X/(X^2+Y^2)+SQR(SQR((1-E)^2+DD)+E-1)/SQR(2))
LET XI=-LOG((SQR(SQR(EE^2+DD)+EE)/SQR(2)-Y/(Y^2+X^2))^2+(X/(X^2+Y^2)+SQR(SQR(EE^2+DD)-EE)/SQR(2))^2)/2
END IF
LET CASEC=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CASEC2(Z)
OPTION ARITHMETIC COMPLEX
LET CASEC2=CATAN(CSQR(Z*Z-1))
END FUNCTION
EXTERNAL FUNCTION CASEC3(Z)
OPTION ARITHMETIC COMPLEX
LET CASEC3=CACOS(1/Z)
END FUNCTION
EXTERNAL FUNCTION CACOTAN(Z) !'arccotangent
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET D=X^2+Y^2
LET XR=(ATAN2(X/D,Y/D+1)+ATAN2(X/D,1-Y/D))/2
LET XI=-LOG((Y/D+1)^2+X^2/D^2)/4+LOG((1-Y/D)^2+X^2/D^2)/4
LET CACOTAN=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CACOTAN2(Z)
OPTION ARITHMETIC COMPLEX
LET CACOTAN2=CATAN(1/Z)
END FUNCTION
! ÁжÊÀþ´Ø¿ô
EXTERNAL FUNCTION CSINH(Z) !'hyperbolic sine
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET XR = SINH(X) * COS(Y)
LET XI = COSH(X) * SIN(Y)
LET CSINH=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CSINH2(Z)
OPTION ARITHMETIC COMPLEX
LET CSINH2=(CEXP(Z)-CEXP(-Z))/2
END FUNCTION
EXTERNAL FUNCTION CCOSH(Z) !'hyperbolic cosine
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET XR = COSH(X) * COS(Y)
LET XI = SINH(X) * SIN(Y)
LET CCOSH=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CCOSH2(Z)
OPTION ARITHMETIC COMPLEX
LET CCOSH2=(CEXP(Z)+CEXP(-Z))/2
END FUNCTION
EXTERNAL FUNCTION CTANH(Z) !'hyperbolic tangent
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET D = COS(2 * Y) + COSH(2 * X)
LET XR = SINH(2 * X) / D
LET XI = SIN(2 * Y) / D
LET CTANH=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CTANH2(Z)
OPTION ARITHMETIC COMPLEX
LET CTANH2=CSINH(Z)/CCOSH(Z)
END FUNCTION
EXTERNAL FUNCTION CTANH3(Z)
OPTION ARITHMETIC COMPLEX
LET CTANH3=-CEXP(-Z)/(CEXP(Z)+CEXP(-Z))*2+1
END FUNCTION
EXTERNAL FUNCTION CCOSECH(Z) !'hyperbolic cosecant
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET D=COSH(X)^2*SIN(Y)^2+SINH(X)^2*COS(Y)^2
LET XR=SINH(X)*COS(Y)/D
LET XI=-COSH(X)*SIN(Y)/D
LET CCOSECH=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CCOSECH2(Z)
OPTION ARITHMETIC COMPLEX
LET CCOSECH2=1/CSINH(Z)
END FUNCTION
EXTERNAL FUNCTION CSECH(Z) !'hyperbolic secant
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET D=SINH(X)^2*SIN(Y)^2+COSH(X)^2*COS(Y)^2
LET XR=COSH(X)*COS(Y)/D
LET XI=-SINH(X)*SIN(Y)/D
LET CSECH=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CSECH2(Z)
OPTION ARITHMETIC COMPLEX
LET CSECH2=1/CCOSH(Z)
END FUNCTION
EXTERNAL FUNCTION CCOTANH(Z) !'hyperbolic cotangent
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET D=COS(2*Y)+COSH(2*X)
LET DD=SIN(2*Y)^2+SINH(2*X)^2
LET XR=SINH(2*X)*D/DD
LET XI=-SIN(2*Y)*D/DD
LET CCOTANH=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CCOTANH2(Z)
OPTION ARITHMETIC COMPLEX
LET CCOTANH2=1/CTANH(Z)
END FUNCTION
EXTERNAL FUNCTION CCOTANH3(Z)
OPTION ARITHMETIC COMPLEX
LET CCOTANH3=CEXP(-Z)/(CEXP(Z)-CEXP(-Z))*2+1
END FUNCTION
! µÕÁжÊÀþ´Ø¿ô
EXTERNAL FUNCTION CASINH(Z) !'arc-hyperbolic sine
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET D=SQR((-Y^2+X^2+1)^2+4*X^2*Y^2)
IF X*Y>=0 THEN
LET XR=LOG((SQR(D+Y^2-X^2-1)/SQR(2)+Y)^2+(SQR(D-Y^2+X^2+1)/SQR(2)+X)^2)/2
LET XI=ATAN2(SQR(D+Y^2-X^2-1)/SQR(2)+Y,SQR(D-Y^2+X^2+1)/SQR(2)+X)
ELSE
LET XR=LOG((Y-SQR(D+Y^2-X^2-1)/SQR(2))^2+(SQR(D-Y^2+X^2+1)/SQR(2)+X)^2)/2
LET XI=-ATAN2(SQR(D+Y^2-X^2-1)/SQR(2)-Y,SQR(D-Y^2+X^2+1)/SQR(2)+X)
END IF
LET CASINH=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CASINH2(Z)
OPTION ARITHMETIC COMPLEX
LET CASINH2=CLOG(Z+CSQR(Z*Z+1))
END FUNCTION
EXTERNAL FUNCTION CACOSH(Z) !'arc-hyperbolic cosine
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET D=SQR(Y^2+(X+1)^2)
LET DD=SQR(Y^2+(X-1)^2)
IF Y>=0 THEN
LET XR=LOG((SQR(D+X+1)/2+SQR(DD+X-1)/2)^2+(SQR(D-X-1)/2+SQR(DD-X+1)/2)^2)
LET XI=2*ATAN2(SQR(D-X-1)/2+SQR(DD-X+1)/2,SQR(D+X+1)/2+SQR(DD+X-1)/2)
ELSE
LET XR=LOG((SQR(D+X+1)/2+SQR(DD+X-1)/2)^2+(-SQR(D-X-1)/2-SQR(DD-X+1)/2)^2)
LET XI=-2*ATAN2(SQR(D-X-1)/2+SQR(DD-X+1)/2,SQR(D+X+1)/2+SQR(DD+X-1)/2)
END IF
LET CACOSH=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CACOSH2(Z)
OPTION ARITHMETIC COMPLEX
LET CACOSH2=CLOG(Z+CSQR(Z*Z-1))
END FUNCTION
EXTERNAL FUNCTION CATANH(Z) !'arc-hyperbolic tangent
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET XR=LOG(Y^2+(X+1)^2)/4-LOG(Y^2+(1-X)^2)/4
LET XI=(ATAN2(Y,X+1)+ATAN2(Y,1-X))/2
LET CATANH=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CATANH2(Z)
OPTION ARITHMETIC COMPLEX
LET CATANH2=CLOG((1+Z)/(1-Z))/2
END FUNCTION
EXTERNAL FUNCTION CACOSECH(Z) !'arc-hyperbolic cosecant
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET S=(X^2-Y^2)^2+4*X^2*Y^2
LET D=Y^2/S
LET DD=X^2/S
LET SS=4*X^2*Y^2/S^2
LET E=(X^2-Y^2)/S
IF X*Y>0 THEN
LET
XR=LOG((-SQR(SQR((-D+DD+1)^2+SS)+D-DD-1)/SQR(2)-Y/(X^2+Y^2))^2+(SQR(SQR((-D+DD+1)^2+SS)-D+DD+1)/SQR(2)+X/(X^2+Y^2))^2)/2
LET XI=-ATAN2(SQR(SQR((E+1)^2+SS)-E-1)/SQR(2)+Y/(X^2+Y^2),SQR(SQR((E+1)^2+SS)+E+1)/SQR(2)+X/(X^2+Y^2))
ELSE
LET
XR=LOG((SQR(SQR((-D+DD+1)^2+SS)+D-DD-1)/SQR(2)-Y/(X^2+Y^2))^2+(SQR(SQR((-D+DD+1)^2+SS)-D+DD+1)/SQR(2)+X/(X^2+Y^2))^2)/2
LET XI=ATAN2(SQR(SQR((E+1)^2+SS)-E-1)/SQR(2)-Y/(X^2+Y^2),SQR(SQR((E+1)^2+SS)+E+1)/SQR(2)+X/(X^2+Y^2))
END IF
LET CACOSECH=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CACOSECH2(Z)
OPTION ARITHMETIC COMPLEX
LET CACOSECH2=CASINH(1/Z)
END FUNCTION
EXTERNAL FUNCTION CACOSECH3(Z)
OPTION ARITHMETIC COMPLEX
LET CACOSECH3=CLOG((CSQR(Z*Z+1)+1)/Z)
END FUNCTION
EXTERNAL FUNCTION CASECH(Z) !'arc-hyperbolic secant
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET D=X/(X^2+Y^2)
LET DD=Y^2/(X^2+Y^2)^2
IF Y>0 THEN
LET
XR=LOG((SQR(SQR((D+1)^2+DD)+D+1)/2+SQR(SQR((D-1)^2+DD)+D-1)/2)^2+(-SQR(SQR((D+1)^2+DD)-D-1)/2-SQR(SQR((D-1)^2+DD)-D+1)/2)^2)
LET
XI=-2*ATAN2(SQR(SQR((D+1)^2+DD)-D-1)/2+SQR(SQR((D-1)^2+DD)-D+1)/2,SQR(SQR((D+1)^2+DD)+D+1)/2+SQR(SQR((D-1)^2+DD)+D-1)/2)
ELSE
LET
XR=LOG((SQR(SQR((D+1)^2+DD)+D+1)/2+SQR(SQR((D-1)^2+DD)+D-1)/2)^2+(SQR(SQR((D+1)^2+DD)-D-1)/2+SQR(SQR((D-1)^2+DD)-D+1)/2)^2)
LET
XI=2*ATAN2(SQR(SQR((D+1)^2+DD)-D-1)/2+SQR(SQR((D-1)^2+DD)-D+1)/2,SQR(SQR((D+1)^2+DD)+D+1)/2+SQR(SQR((D-1)^2+DD)+D-1)/2)
END IF
LET CASECH=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CASECH2(Z)
OPTION ARITHMETIC COMPLEX
LET CASECH2=CACOSH(1/Z)
END FUNCTION
EXTERNAL FUNCTION CASECH3(Z)
OPTION ARITHMETIC COMPLEX
LET CASECH3=CLOG((CSQR(1-Z*Z)+1)/Z)
END FUNCTION
EXTERNAL FUNCTION CACOTANH(Z) !'arc-hyperbolic cotangent
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET D=X/(X^2+Y^2)
LET S=Y/(X^2+Y^2)
LET DD=S^2
LET XR=LOG((D+1)^2+DD)/4-LOG((1-D)^2+DD)/4
LET XI=(-ATAN2(S,D+1)-ATAN2(S,1-D))/2
LET CACOTANH=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CACOTANH2(Z)
OPTION ARITHMETIC COMPLEX
LET CACOTANH2=CATANH(1/Z)
END FUNCTION
EXTERNAL FUNCTION CACOTANH3(Z)
OPTION ARITHMETIC COMPLEX
LET CACOTANH3=CLOG((Z+1)/(Z-1))/2
END FUNCTION
! ¤½¤Î¾
EXTERNAL FUNCTION CABS(Z) !'ÀäÂÐÃÍ
OPTION ARITHMETIC COMPLEX
LET CABS=SQR(RE(Z)^2+IM(Z)^2)
END FUNCTION
EXTERNAL FUNCTION CSQR(Z) !'Ê¿Êýº¬
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET R=SQR(X*X+Y*Y)
LET XR=SQR(R+X)/SQR(2)
IF Y>=0 THEN
LET XI=SQR(R-X)/SQR(2)
ELSE
LET XI=-SQR(R-X)/SQR(2)
END IF
LET CSQR=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CLOG(Z) !'Âпô
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET XR = LOG(X * X + Y * Y) / 2
LET XI = ATAN2(Y, X)
LET CLOG=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CEXP(Z) !'»Ø¿ô
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET XR = EXP(X) * COS(Y)
LET XI = EXP(X) * SIN(Y)
LET CEXP=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CARG(Z) !'ÊгÑ
OPTION ARITHMETIC COMPLEX
LET CARG = ATAN2(IM(Z), RE(Z))
END FUNCTION
EXTERNAL FUNCTION CPOW(X,Y) !'(A+Bi)^(C+Di)
OPTION ARITHMETIC COMPLEX
LET A=RE(X)
LET B=IM(X)
LET C=RE(Y)
LET D=IM(Y)
LET XR=(B^2+A^2)^(C/2)*EXP(-ATAN2(B,A)*D)*COS(LOG(B^2+A^2)*D/2+ATAN2(B,A)*C)
LET XI=(B^2+A^2)^(C/2)*EXP(-ATAN2(B,A)*D)*SIN(LOG(B^2+A^2)*D/2+ATAN2(B,A)*C)
LET CPOW=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL SUB CNPOW(Z, N, V()) !'(A+Bi)^(1/N)
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET R = (X * X + Y * Y)^(1 / (2 * N))
LET TH = ATAN2(Y,X)
LET A = R * COS(TH / N)
LET B = R * SIN(TH / N)
FOR I = 1 TO N
LET C = COS(2 * PI / N * I)
LET S = SIN(2 * PI / N * I)
LET AA = A * C - B * S
LET BB = B * C + A * S
LET V(I) = COMPLEX(AA,BB)
NEXT I
END SUB
EXTERNAL FUNCTION CRUIJYO(Z, N) !'(A+Bi)^N
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
LET N = INT(N)
LET R = (X * X + Y * Y)^(N / 2)
LET TH=ATAN2(Y,X)
LET XR = R * COS(TH * N)
LET XI = R * SIN(TH * N)
LET CRUIJYO=COMPLEX(XR,XI)
END FUNCTION
EXTERNAL FUNCTION CCONJ(Z) !'¶¦Ìò¿ô
OPTION ARITHMETIC COMPLEX
LET CCONJ=COMPLEX(RE(Z),-IM(Z))
END FUNCTION
EXTERNAL FUNCTION REAL(Z) !'¼ÂÉô
OPTION ARITHMETIC COMPLEX
LET REAL=CABS(Z)*COS(CARG(Z))
END FUNCTION
EXTERNAL FUNCTION IMAG(Z) !'µõÉô
OPTION ARITHMETIC COMPLEX
LET IMAG=CABS(Z)*SIN(CARG(Z))
END FUNCTION
EXTERNAL SUB CPRINT(Z)
OPTION ARITHMETIC COMPLEX
LET X=RE(Z)
LET Y=IM(Z)
IF X=0 AND Y=0 THEN
PRINT "0"
EXIT SUB
END IF
IF Y=0 THEN
IF X < 0 THEN PRINT "- ";
PRINT STR$(ABS(X))
EXIT SUB
END IF
IF X=0 THEN
IF Y < 0 THEN PRINT "- ";
IF ABS(Y)= 1 THEN
PRINT "i"
EXIT SUB
END IF
PRINT STR$(ABS(Y)); " i"
EXIT SUB
END IF
IF X < 0 THEN PRINT "- ";
PRINT STR$(ABS(X)); " ";
IF Y < 0 THEN PRINT "- "; ELSE PRINT "+ ";
IF ABS(Y)= 1 THEN
PRINT "i"
EXIT SUB
END IF
PRINT STR$(ABS(Y)); " i"
END SUB
EXTERNAL FUNCTION ATAN2(Y,X) !'-¦Ð¡Á¦Ð
OPTION ARITHMETIC COMPLEX
IF ABS(IM(X))<1E-4 AND ABS(IM(Y))<1E-4 THEN
LET X=RE(X)
LET Y=RE(Y)
ELSE
PRINT "ERROR!!"
STOP
END IF
LET ATAN2=ANGLE(X,Y)
!' LET L=ACOS(X/SQR(X*X+Y*Y))
!' IF Y<0 THEN LET ATAN2=-L ELSE LET ATAN2=L
END FUNCTION
!EXTERNAL FUNCTION ATAN2(Y,X) '0¡Á2¦Ð
!OPTION ARITHMETIC COMPLEX
!IF ABS(IM(X))<1E-4 AND ABS(IM(Y))<1E-4 THEN
! LET X=RE(X)
! LET Y=RE(Y)
!ELSE
! PRINT "ERROR!!"
! STOP
!END IF
!IF X<>0 THEN
! LET TH=ATN(Y/X)
! IF Y<>0 THEN
! IF X>0 AND Y<0 THEN LET TH=TH+PI*2
! IF X<0 THEN LET TH=TH+PI
! ELSE
! IF X<0 THEN LET TH=PI ELSE LET TH=0
! END IF
!ELSE
! LET TH=PI/2
! IF Y<0 THEN LET TH=TH+PI
!END IF
!LET ATAN2=TH
!END FUNCTION
EXTERNAL SUB HORNER(X(),Y(),K())
MAT Y=ZER
LET Y(0)=K(MAXLEVEL)
FOR I=MAXLEVEL-1 TO 0 STEP -1
CALL CMUL2(Y,X)
LET Y(0)=Y(0)+K(I)
NEXT I
END SUB
EXTERNAL SUB SMUL(A(),N)
MAT A=(N)*A
END SUB
EXTERNAL SUB COPY(A(),B())
MAT A=B
END SUB
EXTERNAL SUB CMUL(A(),B(),C())
OPTION BASE 0
DIM T$(15,15)
MAT C=ZER
MAT READ T$
FOR I=0 TO 15
FOR J=0 TO 15
IF A(I)<>0 AND B(J)<>0 THEN
IF T$(I,J)="-0" THEN
LET C(0)=C(0)-A(I)*B(J)
ELSE
LET D=VAL(T$(I,J))
IF D>=0 THEN
LET C(D)=C(D)+A(I)*B(J)
ELSE
LET C(-D)=C(-D)-A(I)*B(J)
END IF
END IF
END IF
NEXT J
NEXT I
DATA 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15 !'16¸µ¿ô¾èÀÑɽ (¥¦¥£¥¥Ú¥Ç¥£¥¢¤è¤ê)
DATA 1, -0, 3, -2, 5, -4, -7, 6, 9, -8,-11, 10,-13, 12, 15,-14
DATA 2, -3, -0, 1, 6, 7, -4, -5, 10, 11, -8, -9,-14,-15, 12, 13
DATA 3, 2, -1, -0, 7, -6, 5, -4, 11,-10, 9, -8,-15, 14,-13, 12
DATA 4, -5, -6, -7, -0, 1, 2, 3, 12, 13, 14, 15, -8, -9,-10,-11
DATA 5, 4, -7, 6, -1, -0, -3, 2, 13,-12, 15,-14, 9, -8, 11,-10
DATA 6, 7, 4, -5, -2, 3, -0, -1, 14,-15,-12, 13, 10,-11, -8, 9
DATA 7, -6, 5, 4, -3, -2, 1, -0, 15, 14,-13,-12, 11, 10, -9, -8
DATA 8, -9,-10,-11,-12,-13,-14,-15,
-0, 1, 2, 3, 4, 5, 6, 7
DATA 9, 8,-11, 10,-13, 12, 15,-14, -1, -0, -3, 2, -5, 4, 7, -6
DATA 10, 11, 8, -9,-14,-15, 12, 13, -2, 3, -0, -1, -6, -7, 4, 5
DATA 11,-10, 9, 8,-15, 14,-13, 12, -3, -2, 1, -0, -7, 6, -5, 4
DATA 12, 13, 14, 15, 8, -9,-10,-11, -4, 5, 6, 7, -0, -1, -2, -3
DATA 13,-12, 15,-14, 9, 8, 11,-10, -5, -4, 7, -6, 1, -0, 3, -2
DATA 14,-15,-12, 13, 10,-11, 8, 9, -6, -7, -4, 5, 2, -3, -0, 1
DATA 15, 14,-13,-12, 11, 10, -9, 8, -7, 6, -5, -4, 3, 2, -1, -0
END SUB
EXTERNAL SUB CMUL2(A(),B())
OPTION BASE 0
DIM C(15)
CALL CMUL(A,B,C)
CALL COPY(A,C)
END SUB
EXTERNAL SUB CADD(A(),B(),C())
MAT C=A+B
END SUB
EXTERNAL SUB CSUB(A(),B(),C())
MAT C=A-B
END SUB
EXTERNAL SUB CDIV(A(),B(),C())
OPTION BASE 0
DIM BB(15),S(15)
CALL CCONJ(B,BB)
CALL CMUL(B,BB,S)
CALL CMUL(A,BB,C)
CALL SMUL(C,1/S(0))
END SUB
EXTERNAL SUB CCONJ(A(),B())
LET B(0)=A(0)
FOR I=1 TO 15
LET B(I)=-A(I)
NEXT I
END SUB
EXTERNAL SUB CPRINT(A())
FOR I=0 TO 15
IF A(I)<>0 THEN
IF A(I)<0 THEN
PRINT " - ";
ELSE
IF I>0 AND A(0)<>0 THEN PRINT " + ";
END IF
IF ABS(A(I))<>1 OR I=0 THEN PRINT STR$(ABS(A(I)));
IF I>0 THEN PRINT MID$("ijklmnopqrstuvw",I,1);
END IF
NEXT I
PRINT
END SUB
EXTERNAL SUB CSIN(X(),Y())
OPTION BASE 0
DIM V(MAXLEVEL)
CALL SINE(V)
CALL HORNER(X,Y,V)
END SUB
EXTERNAL SUB CCOS(X(),Y())
OPTION BASE 0
DIM V(MAXLEVEL)
CALL COSINE(V)
CALL HORNER(X,Y,V)
END SUB
EXTERNAL SUB CTAN(X(),Y())
OPTION BASE 0
DIM XX(15),YY(15)
CALL CSIN(X,XX)
CALL CCOS(X,YY)
CALL CDIV(XX,YY,Y)
END SUB
EXTERNAL SUB CEXP(X(),Y())
OPTION BASE 0
DIM V(MAXLEVEL)
CALL EXPON(V)
CALL HORNER(X,Y,V)
END SUB
EXTERNAL SUB CLOG(X(),Y())
OPTION BASE 0
DIM V(MAXLEVEL),A(15),B(15),C(15)
CALL LN(V)
CALL COPY(A,X)
CALL COPY(B,X)
LET A(0)=A(0)-1
LET B(0)=B(0)+1
CALL CDIV(A,B,C)
CALL HORNER(C,Y,V)
CALL SMUL(Y,2)
END SUB
EXTERNAL SUB CPOWER(X(),Y(),A())
OPTION BASE 0
DIM XX(15),YY(15)
CALL COPY(YY,Y)
CALL CLOG(X,XX)
CALL CMUL2(YY,XX)
CALL CEXP(YY,A)
END SUB
EXTERNAL SUB SINE(X())
!'SIN(X)
LET X(1)=1
LET T=1
FOR I=3 TO MAXLEVEL STEP 2
LET T=-T/(I-1)/I
LET X(I)=T
NEXT I
END SUB
EXTERNAL SUB COSINE(X())
!'COS(X)
LET X(0)=1
LET T=1
FOR I=2 TO MAXLEVEL STEP 2
LET T=-T/(I-1)/I
LET X(I)=T
NEXT I
END SUB
EXTERNAL SUB EXPON(X())
!'EXP(X)
LET X(0)=1
LET T=1
FOR I=1 TO MAXLEVEL
LET T=T/I
LET X(I)=T
NEXT I
END SUB
EXTERNAL SUB LN(X())
!'LOG((X-1)/(X+1))
FOR I=1 TO MAXLEVEL
IF MOD(I,2)=1 THEN LET X(I)=1/I
NEXT I
END SUB
OPTION ARITHMETIC COMPLEX
LET N=10 !'õº÷ÈÏ°Ï
DIM P(-N TO N,-N TO N)
FOR X=0 TO N
FOR Y=0 TO N
LET Z=COMPLEX(X,Y)
PRINT Z;":";
LET FL=0
MAT P=ZER
LET P(0,0)=1 !'0,¡Þ1,¡Þi¤ÏÌó¿ô(?)¤Ç¤Ï¤Ê¤¤
LET P(1,0)=1
LET P(0,1)=1
LET P(-1,0)=1
LET P(0,-1)=1
IF P(RE(Z),IM(Z))=0 THEN
!'IF ISGAUSSIANPRIME(Z)<>0 THEN
!' PRINT "ÁÇ¿ô";
!'ELSE
FOR A=0 TO N
FOR B=0 TO N
FOR I=1 TO -1 STEP -2
FOR
J=1 TO -1 STEP -2
LET V=COMPLEX(A*I,B*J)
IF V<>0 THEN
LET
S=Z/V
IF
CMOD(Z,V)=0 AND P(RE(S),IM(S))=0 AND P(RE(V),IM(V))=0 THEN
PRINT "{";V;",";S;"}";
LET P(RE(S),IM(S))=1
LET P(RE(V),IM(V))=1
LET FL=1
END
IF
END IF
NEXT J
NEXT I
NEXT B
NEXT A
IF FL=0 THEN PRINT "ÁÇ¿ô";
!' END IF
END IF
PRINT
NEXT Y
NEXT X
END
EXTERNAL FUNCTION CINT(Z)
OPTION ARITHMETIC COMPLEX
LET CINT=COMPLEX(INT(RE(Z)),INT(IM(Z)))
END FUNCTION
EXTERNAL FUNCTION CMOD(X,Y)
OPTION ARITHMETIC COMPLEX
LET CMOD=X-CINT(X/Y)*Y
END FUNCTION
EXTERNAL FUNCTION ISGAUSSIANPRIME(Z) !'¥¬¥¦¥¹ÁÇ¿ô
OPTION ARITHMETIC COMPLEX
LET ISGAUSSIANPRIME=0
LET A = ABS(RE(Z))
LET B = ABS(IM(Z))
IF A = 0 THEN
IF MOD(B, 4) = 3 AND ISPRIME(B)<>0 THEN LET ISGAUSSIANPRIME=-1
END IF
IF B = 0 THEN
IF MOD(A , 4) = 3 AND ISPRIME(A)<>0 THEN LET ISGAUSSIANPRIME=-1
END IF
IF ISPRIME(A*A+B*B)<>0 THEN LET ISGAUSSIANPRIME=-1
END FUNCTION
EXTERNAL FUNCTION ISPRIME(X)
OPTION ARITHMETIC COMPLEX
IF X=0 OR X=1 THEN
LET ISPRIME=0
EXIT FUNCTION
END IF
IF X=2 THEN
LET ISPRIME=-1
EXIT FUNCTION
END IF
IF MOD(X,2)=0 THEN
LET ISPRIME=0
EXIT FUNCTION
END IF
FOR I=3 TO INT(SQR(X)) STEP 2
IF MOD(X,I)=0 THEN
LET ISPRIME=0
EXIT FUNCTION
END IF
NEXT I
LET ISPRIME=-1
END FUNCTION
PUBLIC NUMERIC N
LET N=10 !'õº÷ÈÏ°Ï (+n+ni+nj+nj+nk..)¡Á(-n-ni-nj-nj-nk..) (i,j,k...¤Ïµõ¿ôñ°Ì)
DO
READ L
IF L=0 THEN STOP
DATA 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97
DATA 0
PRINT L;":";
IF CHECK(L)=1 THEN PRINT "ÁÇ¿ô"
LOOP
END
EXTERNAL FUNCTION CHECK(L) !'¥ª¥¯¥È¥Ë¥ª¥ó(8¸µ¿ô)õº÷ (8½Å¥ë¡¼¥×)
OPTION BASE 0
DIM X(15),Y(15),Z(15)
LET X(0)=L
FOR H=0 TO N
FOR S8=1 TO -1 STEP -2
LET Y(7)=H*S8
FOR G=0 TO N
FOR S7=1 TO -1 STEP -2
LET Y(6)=G*S7
FOR F=0 TO N
FOR S6=1 TO -1 STEP -2
LET Y(5)=F*S6
FOR E=0 TO N
FOR S5=1 TO -1 STEP -2
LET
Y(4)=E*S5
FOR
D=0 TO N
FOR S4=1 TO -1 STEP -2
LET
Y(3)=D*S4
FOR
C=0 TO N
FOR S3=1 TO -1 STEP -2
LET
Y(2)=C*S3
FOR
B=0 TO N
FOR S2=1 TO -1 STEP -2
LET
Y(1)=B*S2
FOR
A=0 TO N
FOR S1=1 TO -1 STEP -2
LET
Y(0)=A*S1
IF
COMP(Y)=0 THEN
CALL CDIV(X,Y,Z)
IF COMP(Z)=0 THEN
LET
FR=0
FOR
I=0 TO 15
IF FRAC(Z(I))<>0 THEN
LET
FR=1
EXIT
FOR
END IF
NEXT
I
IF
FR=0 THEN
PRINT "{";
CALL CPRINT(Y)
PRINT ",";
CALL CPRINT(Z)
PRINT "}"
LET CHECK=0
EXIT FUNCTION !'¸«¤Ä¤±¼¡Âè¥ë¡¼¥×ÂǤÁÀÚ¤ê
END
IF
END IF
END
IF
NEXT S1
NEXT A
NEXT S2
NEXT B
NEXT S3
NEXT
C
NEXT S4
NEXT D
NEXT S5
NEXT E
NEXT S6
NEXT F
NEXT S7
NEXT G
NEXT S8
NEXT H
LET CHECK=1
END FUNCTION
EXTERNAL FUNCTION COMP(Y())
OPTION BASE 0
DIM Z(15)
FOR I=1 TO 16
LET FL=0
MAT READ Z
DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 !'0
DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 !'1
DATA -1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0 !'i
DATA 0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0, 1,0,0,0,0,0,0,0,0,0,0,0,0,0 !'j
DATA 0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0, 1,0,0,0,0,0,0,0,0,0,0,0,0 !'k
DATA 0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0, 1,0,0,0,0,0,0,0,0,0,0,0 !'l
DATA 0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0, 1,0,0,0,0,0,0,0,0,0,0 !'m
DATA 0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0, 1,0,0,0,0,0,0,0,0,0 !'n
DATA 0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0,0
DATA 0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0,0 !'o
DATA 0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0,0
!'DATA 0,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0
!'DATA 0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0,0
!'DATA 0,0,0,0,0,0,0,0,0, 1,0,0,0,0,0,0
!'DATA 0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0,0
!'DATA 0,0,0,0,0,0,0,0,0,0, 1,0,0,0,0,0
!'DATA 0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0,0
!'DATA 0,0,0,0,0,0,0,0,0,0,0, 1,0,0,0,0
!'DATA 0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0,0
!'DATA 0,0,0,0,0,0,0,0,0,0,0,0, 1,0,0,0
!'DATA 0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0,0
!'DATA 0,0,0,0,0,0,0,0,0,0,0,0,0, 1,0,0
!'DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0,0
!'DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1,0
!'DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1,0
!'DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1
!'DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-1
FOR J=0 TO 15
IF Y(J)=Z(J) THEN LET FL=FL+1 !'0,¡Þ1,¡Þi,¡Þj,¡Þk...¤ÏÌó¿ô(?)¤Ç¤Ï¤Ê¤¤
NEXT J
IF FL=16 THEN
LET COMP=1
EXIT FUNCTION
END IF
NEXT I
LET COMP=0
END FUNCTION
EXTERNAL FUNCTION FRAC(X) !'¾®¿ôÉô
LET FRAC=X-INT(X)
END FUNCTION
EXTERNAL SUB CDIV(A(),B(),C())
OPTION BASE 0
DIM BB(15),S(15)
CALL CCONJ(B,BB)
CALL CMUL(B,BB,S)
CALL CMUL(A,BB,C)
MAT C=(1/S(0))*C
END SUB
EXTERNAL SUB CCONJ(A(),B()) !'¶¦Ìò¿ô
LET B(0)=A(0)
FOR I=1 TO 15
LET B(I)=-A(I)
NEXT I
END SUB
EXTERNAL SUB CPRINT(A())
FOR I=0 TO 15
IF A(I)<>0 THEN
IF A(I)<0 THEN
PRINT " - ";
ELSE
IF I>0 THEN PRINT " + ";
END IF
IF ABS(A(I))<>1 OR I=0 THEN PRINT STR$(ABS(A(I)));
IF I>0 THEN PRINT MID$("ijklmnopqrstuvw",I,1);
END IF
NEXT I
END SUB
EXTERNAL SUB CMUL(A(),B(),S())
LET
S(0)=A(0)*B(0)-A(1)*B(1)-A(2)*B(2)-A(3)*B(3)-A(4)*B(4)-A(5)*B(5)-A(6)*B(6)-A(7)*B(7)-A(8)*B(8)-A(9)*B(9)-A(10)*B(10)-A(11)*B(11)-A(12)*B(12)-A(13)*B(13)-A(14)*B(14)-A(15)*B(15)
LET
S(1)=A(0)*B(1)+A(1)*B(0)+A(2)*B(3)-A(3)*B(2)+A(4)*B(5)-A(5)*B(4)-A(6)*B(7)+A(7)*B(6)+A(8)*B(9)-A(9)*B(8)-A(10)*B(11)+A(11)*B(10)-A(12)*B(13)+A(13)*B(12)+A(14)*B(15)-A(15)*B(14)
LET
S(2)=A(0)*B(2)-A(1)*B(3)+A(2)*B(0)+A(3)*B(1)+A(4)*B(6)+A(5)*B(7)-A(6)*B(4)-A(7)*B(5)+A(8)*B(10)+A(9)*B(11)-A(10)*B(8)-A(11)*B(9)-A(12)*B(14)-A(13)*B(15)+A(14)*B(12)+A(15)*B(13)
LET
S(3)=A(0)*B(3)+A(1)*B(2)-A(2)*B(1)+A(3)*B(0)+A(4)*B(7)-A(5)*B(6)+A(6)*B(5)-A(7)*B(4)+A(8)*B(11)-A(9)*B(10)+A(10)*B(9)-A(11)*B(8)-A(12)*B(15)+A(13)*B(14)-A(14)*B(13)+A(15)*B(12)
LET
S(4)=A(0)*B(4)-A(1)*B(5)-A(2)*B(6)-A(3)*B(7)+A(4)*B(0)+A(5)*B(1)+A(6)*B(2)+A(7)*B(3)+A(8)*B(12)+A(9)*B(13)+A(10)*B(14)+A(11)*B(15)-A(12)*B(8)-A(13)*B(9)-A(14)*B(10)-A(15)*B(11)
LET
S(5)=A(0)*B(5)+A(1)*B(4)-A(2)*B(7)+A(3)*B(6)-A(4)*B(1)+A(5)*B(0)-A(6)*B(3)+A(7)*B(2)+A(8)*B(13)-A(9)*B(12)+A(10)*B(15)-A(11)*B(14)+A(12)*B(9)-A(13)*B(8)+A(14)*B(11)-A(15)*B(10)
LET
S(6)=A(0)*B(6)+A(1)*B(7)+A(2)*B(4)-A(3)*B(5)-A(4)*B(2)+A(5)*B(3)+A(6)*B(0)-A(7)*B(1)+A(8)*B(14)-A(9)*B(15)-A(10)*B(12)+A(11)*B(13)+A(12)*B(10)-A(13)*B(11)-A(14)*B(8)+A(15)*B(9)
LET
S(7)=A(0)*B(7)-A(1)*B(6)+A(2)*B(5)+A(3)*B(4)-A(4)*B(3)-A(5)*B(2)+A(6)*B(1)+A(7)*B(0)+A(8)*B(15)+A(9)*B(14)-A(10)*B(13)-A(11)*B(12)+A(12)*B(11)+A(13)*B(10)-A(14)*B(9)-A(15)*B(8)
LET
S(8)=A(0)*B(8)-A(1)*B(9)-A(2)*B(10)-A(3)*B(11)-A(4)*B(12)-A(5)*B(13)-A(6)*B(14)-A(7)*B(15)+A(8)*B(0)+A(9)*B(1)+A(10)*B(2)+A(11)*B(3)+A(12)*B(4)+A(13)*B(5)+A(14)*B(6)+A(15)*B(7)
LET
S(9)=A(0)*B(9)+A(1)*B(8)-A(2)*B(11)+A(3)*B(10)-A(4)*B(13)+A(5)*B(12)+A(6)*B(15)-A(7)*B(14)-A(8)*B(1)+A(9)*B(0)-A(10)*B(3)+A(11)*B(2)-A(12)*B(5)+A(13)*B(4)+A(14)*B(7)-A(15)*B(6)
LET
S(10)=A(0)*B(10)+A(1)*B(11)+A(2)*B(8)-A(3)*B(9)-A(4)*B(14)-A(5)*B(15)+A(6)*B(12)+A(7)*B(13)-A(8)*B(2)+A(9)*B(3)+A(10)*B(0)-A(11)*B(1)-A(12)*B(6)-A(13)*B(7)+A(14)*B(4)+A(15)*B(5)
LET
S(11)=A(0)*B(11)-A(1)*B(10)+A(2)*B(9)+A(3)*B(8)-A(4)*B(15)+A(5)*B(14)-A(6)*B(13)+A(7)*B(12)-A(8)*B(3)-A(9)*B(2)+A(10)*B(1)+A(11)*B(0)-A(12)*B(7)+A(13)*B(6)-A(14)*B(5)+A(15)*B(4)
LET
S(12)=A(0)*B(12)+A(1)*B(13)+A(2)*B(14)+A(3)*B(15)+A(4)*B(8)-A(5)*B(9)-A(6)*B(10)-A(7)*B(11)-A(8)*B(4)+A(9)*B(5)+A(10)*B(6)+A(11)*B(7)+A(12)*B(0)-A(13)*B(1)-A(14)*B(2)-A(15)*B(3)
LET
S(13)=A(0)*B(13)-A(1)*B(12)+A(2)*B(15)-A(3)*B(14)+A(4)*B(9)+A(5)*B(8)+A(6)*B(11)-A(7)*B(10)-A(8)*B(5)-A(9)*B(4)+A(10)*B(7)-A(11)*B(6)+A(12)*B(1)+A(13)*B(0)+A(14)*B(3)-A(15)*B(2)
LET
S(14)=A(0)*B(14)-A(1)*B(15)-A(2)*B(12)+A(3)*B(13)+A(4)*B(10)-A(5)*B(11)+A(6)*B(8)+A(7)*B(9)-A(8)*B(6)-A(9)*B(7)-A(10)*B(4)+A(11)*B(5)+A(12)*B(2)-A(13)*B(3)+A(14)*B(0)+A(15)*B(1)
LET
S(15)=A(0)*B(15)+A(1)*B(14)-A(2)*B(13)-A(3)*B(12)+A(4)*B(11)+A(5)*B(10)-A(6)*B(9)+A(7)*B(8)-A(8)*B(7)+A(9)*B(6)-A(10)*B(5)-A(11)*B(4)+A(12)*B(3)+A(13)*B(2)-A(14)*B(1)+A(15)*B(0)
END SUB
100 SET WINDOW 2,10,5,13
!SET WINDOW -4,4,-4,4
!SET WINDOW -3,5,4,12
110 LET a=1 ! a=.425
120 LET b=1
130 DRAW AXES(a,b)
!DRAW AXES0(a,b)
!DRAW GRID(a,b)
!DRAW GRID0(a,b) ! Áȹþ¤ß³¨ÄêµÁ
140 END
REM ** ºÂɸ¿ô»ú°ÌÃÖ¼«Æ°Ä´À° **
EXTERNAL PICTURE AXES(p,q)
DRAW axes_grid("on","ax",STR$(p),STR$(q))
END PICTURE
EXTERNAL PICTURE AXES0(p,q)
DRAW axes_grid("off","ax",STR$(p),STR$(q))
END PICTURE
EXTERNAL PICTURE GRID(p,q)
DRAW axes_grid("on","gr",STR$(p),STR$(q))
END PICTURE
!
!½½¿ÊBASICźÉÕ"\BASICw32\Library\Grid2.lib"»²¾È
! num$="off"¿ô»ú̵,"on"¿ô»úÍ , ag$="ax"¼´,"gr"³Ê»Ò , sx=x¼´ÌÜÀ¹´Ö³Ö , sy=y¼´ÌÜÀ¹´Ö³Ö
EXTERNAL PICTURE axes_grid(num$,ag$,sx$,sy$)
OPTION ARITHMETIC DECIMAL
FUNCTION val_r(f$) ! ÍÍý¿ô¤ò¾®¿ô¤ËÊÑ´¹
LET vrp=POS(f$,"/")
IF vrp=0 THEN LET val_r=VAL(f$) ELSE LET val_r=VAL(f$(1:vrp-1))/VAL(f$(vrp+1:LEN(f$)))
END FUNCTION
FUNCTION round_cut$(a$,A,s) ! ¾®¿ô·å¥«¥Ã¥È
ASK TEXT WIDTH(a$) w
LET d=LEN(a$)
LET p=POS(a$,".")
IF w>s AND p>0 AND
POS(a$,"E")=0 AND d>2 AND NOT(d=3 AND a$(1:2)="-." OR a$(d:d)=".")
THEN
LET a$=STR$(SGN(A)*ROUND(ABS(A),d-p-1))
! LET a$=STR$(ROUND(A,d-p-1))
IF
POS(a$,".")>0 THEN LET a$=a$&"00000000" ELSE LET
a$=a$&".00000000"
LET a$=round_cut$(a$(1:d-1),A,s)
END IF
LET round_cut$=a$
END FUNCTION
LET sx=val_r(sx$)
LET sy=val_r(sy$)
ASK WINDOW L,R,B,T
ASK LINE STYLE S
ASK LINE COLOR C
SET LINE COLOR 15 ! ¶ä¿§
ASK TEXT COLOR TC
SET TEXT COLOR 15 ! ¶ä¿§
ASK TEXT JUSTIFY ts1$,ts2$
SET LINE STYLE 1
PLOT LINES:L,0;R,0 ! x¼´
PLOT LINES:0,B;0,T ! y¼´
IF ag$="gr" THEN SET LINE STYLE 3
IF sx<>0 THEN
IF B*T<0 OR T=0 THEN SET TEXT
JUSTIFY "RIGHT","TOP" ELSE SET TEXT JUSTIFY "RIGHT","BOTTOM"
IF B*T<0 OR T=0 THEN LET y0=0 ELSE LET y0=B
LET wy=WORLDY(PIXELY(0)+2)
LET n=ABS(INT(LOG10(sx)-2))
FOR X=CEIL(L/sx)*sx TO INT(R/sx)*sx+1.001*sx STEP sx
IF ag$="gr" THEN PLOT LINES:X,B;X,T ELSE PLOT LINES:X,-wy;X,wy
IF y0=B AND ag$="ax" THEN
PLOT LINES:X,B-(T-B)/100;X,WORLDY(3) ! ²¼Ã¼ÌÜÀ¹Àþ
PLOT LINES:X,T+(T-B)/100;X,WORLDY(PIXELY(T)-3) ! ¾åüÌÜÀ¹Àþ
END IF
IF
num$="on" THEN PLOT TEXT,AT X,y0 : round_cut$(STR$(ROUND(X,n)),X,sx)
NEXT X
END IF
IF sy<>0 THEN
IF L*R<0 OR R=0 THEN SET TEXT JUSTIFY "RIGHT","TOP" ELSE SET TEXT JUSTIFY "LEFT","TOP"
IF L*R<0 OR R=0 THEN LET x0=0 ELSE LET x0=L
LET wx=WORLDX(PIXELX(0)+2)
LET n=ABS(INT(LOG10(sy)-2))
FOR Y=CEIL(B/sy)*sy TO INT(T/sy)*sy+1.001*sy STEP sy
IF ag$="gr" THEN PLOT LINES:L,Y;R,Y ELSE PLOT LINES:-wx,Y;wx,Y
IF x0=L AND ag$="ax" THEN
PLOT LINES:L-(R-L)/100,Y;WORLDX(3),Y ! º¸Ã¼ÌÜÀ¹Àþ
PLOT LINES:R+(R-L)/100,Y;WORLDX(PIXELX(R)-3),Y ! ±¦Ã¼ÌÜÀ¹Àþ
END IF
IF num$="on" THEN PLOT TEXT,AT x0,Y : STR$(ROUND(Y,n))
NEXT Y
END IF
SET TEXT JUSTIFY "RIGHT","TOP"
IF num$="on" AND sx=0 AND sy=0 THEN PLOT TEXT,AT 0,0:STR$(0)
SET LINE COLOR C
SET LINE STYLE S
SET TEXT COLOR TC
SET TEXT JUSTIFY ts1$,ts2$
END PICTURE
!DQT
SUB FFDB
DO WHILE 0< N
CALL RED_D
LET w= IP(ORD(D$)/16) !p=0(byte) p=1(word)
LET J=MOD(ORD(D$),16) !J=0~3 (QT.number)
FOR i=0 TO 63
CALL RED_D
LET DQ(U(i),V(i),J)=ORD(D$)
IF w=1 THEN
CALL RED_D
LET DQ(U(i),V(i),J)=DQ(U(i),V(i),J)*256+ORD(D$)
END IF
NEXT i
LET N=N-65-64*w ! remain size
LOOP
END SUB
!SOF0
SUB FFC0
CALL RED_D
IF ORD(D$)<>8 THEN BREAK ! 8bit( 24bitColor ) at RGB.dimension
CALL RED_D
LET W=ORD(D$)*256
CALL RED_D
LET DY=W+ORD(D$) !V.pix.
CALL RED_D
LET W=ORD(D$)*256
CALL RED_D
LET DX=W+ORD(D$) !H.pix.
CALL RED_D
FOR i=0 TO ORD(D$)-1 !1~3 scan order items
CALL RED_D
LET CoID(ORD(D$))=i ! (Y=0, Cb=1, Cr=2)<-- CoID( ID=0~255)
CALL RED_D
LET MH(i)= IP(ORD(D$)/16) ! HV Y=11,12,21,22,41 Cb=11,11,11,11,11 Cr=11,11,11,11,11
LET MV(i)=MOD(ORD(D$),16)
CALL RED_D
LET QS(i)=ORD(D$) ! QT.number0~3 <-- QS( Y=0, Cb=1, Cr=2)
NEXT i
IF 2< i THEN LET CMO=2 ELSE LET CMO=0
END SUB
!DHT
SUB FFC4
DO WHILE 0< N
CALL RED_D
LET
J=ORD(D$) !
0?~1?=DC~AC ?0~?3=ID0~ID3
LET J=2*MOD(J,16)+IP(J/16) ! 0~1=ID0.DC~AC 2~3=ID1.DC~AC 4~5=ID2.¡Ä
LET DH(0,J)=0 !!!for 2nd.use for clear
FOR i=1 TO 16
CALL RED_D
LET DH(i,J)=ORD(D$)
LET DH(0,J)=DH(0,J)+DH(i,J)
NEXT i
FOR i=0 TO DH(0,J)-1
CALL RED_D
LET DV(i,J)=ORD(D$)
NEXT i
!---
FOR i=i TO 255
LET DV(i,J)=0
NEXT i
CALL makeH0(J) ! make Huffman Code table B() L()
CALL makeD0(J) ! make Huffman Decorder table A()
!---
LET N=N-1-16-DH(0,J) ! remain size
LOOP
END SUB
!SOS
SUB FFDA
CALL RED_D
LET M2=ORD(D$)
MAT HDC=(-2)*CON
MAT HAC=(-2)*CON
FOR i=1 TO M2
CALL RED_D
LET w=ORD(D$) !ID=0~255( normal 01~03)
CALL RED_D ! 00=Y 11=Cb 11=Cr
LET HDC(CoID(w))= IP(ORD(D$)/16)*2 !DC 0~3-->0,2,4,6
LET HAC(CoID(w))=MOD(ORD(D$),16)*2+1 !AC 0~3-->1,3,5,7
NEXT i
CALL RED_D
LET Ss_=ORD(D$) ! low of spectral selection
CALL RED_D
LET Se_=ORD(D$) ! high of spectral selection
CALL RED_D
LET Al=MOD(ORD(D$),16) ! low bit of successive approximation
LET Ah=IP(ORD(D$)/16) !high bit of successive approximation
!--- private controll M3(display timing)
LET w=Ah-Al
IF w=0 THEN LET w=1
FOR i=0 TO 2
IF 0<=HAC(i) THEN LET M3(i)=M3(i)+(Se_-Ss_+1)*w ! M3()= scan band sum
NEXT i
!--- next image data top
END SUB
SUB ROPEN
OPEN #1 :NAME FL$ ,ACCESS INPUT
END SUB
SUB RED_D
CHARACTER INPUT #1 :D$
LET byt=byt+1 !!!
END SUB
!============
! B(,J)L(,J)<-- DH(,J) for decorder table A(,J)
!
SUB makeH0(J)
LET i=0 ! ¥³¡¼¥ÉÀ¸À® ½çÈÖ(û¤¤½ç)
LET Hx=0
LET Tx=BVAL("8000",16)
FOR L_=1 TO 16
FOR P=1 TO DH(L_,J)
LET L(i,J)=L_
LET B(i,J)=Hx ! ¥³¡¼¥É(À¸À®½ç), ºÂɸDV(ÉÑÅٹ߽ç) ¤ÈƱ½ç¡£
LET i=i+1
LET Hx=Hx+Tx
NEXT P
LET Tx=Tx/2
NEXT L_
LET B(256,J)=0
FOR i=i TO 255
LET L(i,J)=0
LET B(i,J)=0
NEXT i
END SUB
!============
!A(,J)=output decorder table<-- B(,J) L(,J) DH(,J) DV(,J)
!
SUB makeD0(J)
FOR LH=16 TO 1 STEP -1
IF DH(LH,J)<>0 THEN EXIT FOR
NEXT
LH
!length max. in huffman table
LET LM=CEIL(LH/BST)*BST !length max. bound by BST
!---
LET I=0 !start huffman table adr.
LET LA=0 !line adr.
LET P=BST !start Decord code width
LET U_=2^(16-BST) !start Decord code step
LET NC=0 !next start Decord code
DO
LET D_=NC !start Decord code
LET NC=-1
LET LB=LA+(65536-D_)/U_ !1st nest adr.
DO
CALL SERCH
IF 0< L_ THEN
LET
A(LA,J)= BVAL("8000",16)+L_*256+DV(I,J) !b15=end. +L.+V.
ELSEIF P=LM THEN
LET
A(LA,J)= BVAL("C000",16)+LH*256 !b15=end. b14=Unused. +L.
ELSE
IF NC=-1 THEN LET NC=D_
LET A(LA,J)=LB ! nest adr.
LET LB=LB+SHb ! next nest adr.
END IF
LET D_=D_+U_
LET LA=LA+1
LOOP UNTIL IP(D_)=65536
LET P=P+BST
LET U_=U_/SHb !shr(U_,BST)
LOOP UNTIL P>LM
!---
FOR LA=LA TO 255
LET A(LA,J)=0 !(0),table stop mark
NEXT LA
END SUB
SUB SERCH
FOR I=I TO DH(0,J)-1
LET L_=L(I,J)
IF L_<=P THEN LET w=IP(D_/2^(16-L_))*2^(16-L_) ELSE EXIT FOR
IF w<=B(I,J) THEN
IF w=B(I,J) THEN EXIT SUB ELSE EXIT FOR
END IF
NEXT I
LET L_=-1
END SUB
!===========
! Inverse Fast Cosin Transform.( 8x8, iDCT-2 ) ¢« Inverse Quantization.DQ()
SUB IDDCT8X8
FOR V0=0 TO DV_-1 STEP 8
FOR U0=0 TO DU-1 STEP 8
FOR P=0 TO CMO ! =0(mono) =2(color)
FOR V_=0 TO 7
FOR U_=0 TO 7
LET
X(U_)=D2(U0+U_,V0+V_,P) *DQ(U_,V_,QS(P)) ! Inverse Quantization
NEXT U_
CALL IWANG
FOR X_=0 TO 7
LET T(X_,V_)=X(X_)
NEXT X_
NEXT V_
FOR X_=0 TO 7
FOR V_=0 TO 7
LET X(V_)=T(X_,V_)
NEXT V_
CALL IWANG
FOR Y_=0 TO 7
IF
P=0 THEN LET D1(U0+X_,V0+Y_,P)=X(Y_)+128 ELSE LET
D1(U0+X_,V0+Y_,P)=X(Y_)
NEXT Y_
NEXT X_
NEXT P
NEXT U0
NEXT V0
END SUB
!----inverse Wang.( 8, iDCT-2 )
SUB IWANG
LET XO(0)=SQR(2/8)*X(0)
LET XO(1)=SQR(2/8)*X(4)
LET XO(2)=SQR(2/8)*X(2)
LET XO(3)=SQR(2/8)*X(6)
LET XO(4)=SQR(1/8)*X(1)
LET XO(5)=SQR(1/8)*X(5)
LET XO(6)=SQR(1/8)*X(3)
LET XO(7)=SQR(1/8)*X(7)
!
LET X(4)=(COS(PI /16)*XO(4)+SIN(PI /16)*XO(7))
LET X(5)=(COS(PI*5/16)*XO(5)+SIN(PI*5/16)*XO(6))
LET X(6)=(SIN(PI*5/16)*XO(5)-COS(PI*5/16)*XO(6))
LET X(7)=(SIN(PI /16)*XO(4)-COS(PI /16)*XO(7))
!
LET XO(4)= X(4)+X(5)
LET XO(5)= X(4)-X(5)
LET XO(6)=-X(6)+X(7)
LET XO(7)= X(6)+X(7)
!
LET X(0)=(COS(PI/4)*XO(0)+COS(PI /4)*XO(1))
LET X(1)=(COS(PI/4)*XO(0)-COS(PI /4)*XO(1))
LET X(2)=(SIN(PI/8)*XO(2)-SIN(PI*3/8)*XO(3))
LET X(3)=(COS(PI/8)*XO(2)+COS(PI*3/8)*XO(3))
LET X(4)=XO(4)
LET X(5)=XO(6)
LET X(6)=XO(5)
LET X(7)=XO(7)
!
LET XO(0)=X(0)+X(3)
LET XO(1)=X(1)+X(2)
LET XO(2)=X(1)-X(2)
LET XO(3)=X(0)-X(3)
LET XO(4)=X(7)*SQR(2)
LET XO(5)=X(6)-X(5)
LET XO(6)=X(6)+X(5)
LET XO(7)=X(4)*SQR(2)
!
LET X(0)=XO(0)+XO(7)
LET X(1)=XO(1)+XO(6)
LET X(2)=XO(2)+XO(5)
LET X(3)=XO(3)+XO(4)
LET X(4)=XO(3)-XO(4)
LET X(5)=XO(2)-XO(5)
LET X(6)=XO(1)-XO(6)
LET X(7)=XO(0)-XO(7)
END SUB
!=============
SUB R_BIN31(M) ! decord(M) before new.search(M)
DO
IF M=BVAL("D8",16) THEN ! SOI
MAT DH=ZER ! clear Huffman Table
LET
DRI=0 ! clear Restart Interval.value for
RST0~7(restart marker)
LET rct=-1
! Interval.counter, valid (0<=rct), invalid (rct< 0)
MAT M3=ZER ! clear scan band sum
ELSEIF M=BVAL("D9",16) THEN ! EOI
EXIT DO ! close & end_sub
ELSEIF BVAL("D0",16)<=M AND M<=BVAL("D7",16) THEN ! RST0~7( restart marker)
LET rct=DRI ! set counter with Restart Interval
EXIT SUB
ELSEIF 0< M THEN !M=0 is data"FF" in picture area
CALL RED_D
LET N=ORD(D$)*256
CALL RED_D
LET N=N+ORD(D$)-2 ! N=remain size
!---
IF BVAL("E0",16)<=M AND M<=BVAL("EF",16) THEN ! APP0~APP15
CALL FFE0
ELSEIF M=BVAL("DD",16) THEN
CALL FFDD ! DRI load DRI & rct=DRI
ELSEIF M=BVAL("FE",16) THEN
CALL FFFE ! COMMENT
ELSEIF M=BVAL("C4",16) THEN
CALL FFC4 ! DHT
ELSEIF M=BVAL("DB",16) THEN
CALL FFDB ! DQT
ELSEIF M=BVAL("C0",16) OR M=BVAL("C2",16) THEN
CALL FFC0 ! SOF0 SOF2
ELSEIF M=BVAL("DA",16) THEN
CALL FFDA ! SOS
EXIT SUB ! without close
ELSE
BREAK ! new marker
END IF
END IF
!---
DO
LET M=BVAL("D9",16) ! EOI, 256 ! end of file
CHARACTER INPUT #1,IF MISSING THEN EXIT DO :D$
LET byt=byt+1 !!!
LET M=ORD(D$)
LOOP UNTIL M=255 ! 1st.mark
IF M<>255 THEN EXIT DO ! close & end_sub
CALL RED_D
LET M=ORD(D$)
LOOP
CLOSE #1
END SUB
!DRI
SUB FFDD
CALL RED_D
LET DRI=ORD(D$)*256
CALL RED_D
LET DRI=DRI+ORD(D$)
LET rct=DRI
END SUB
!APP0
SUB FFE0
FOR W=1 TO N
CALL RED_D
NEXT W
END SUB
!COMMENT
SUB FFFE
FOR W=1 TO N
CALL RED_D
NEXT W
END SUB
SUB frame
PRINT " Ss Se AhAl: ";Ss_;Se_;STR$(Ah);STR$(Al)
PRINT " Y HDC HAC: ";IP(HDC(0)/2);IP(HAC(0)/2)
PRINT " Cb : ";IP(HDC(1)/2);IP(HAC(1)/2)
PRINT " Cr : ";IP(HDC(2)/2);IP(HAC(2)/2)
CALL reset0
!---
FOR V09=0 TO DV_-1 STEP 8*MV(0)
FOR U09=0 TO DU-1 STEP 8*MH(0)
IF rct=0 THEN
CALL
R_BIN31(0) ! read marker
IF rct<>DRI THEN BREAK ! not RST0~7
CALL reset0 ! Restart
END IF
CALL MCUxx11 ! read picture data
LET rct=rct-1
!---
IF 0< ext THEN
IF ext=103001 THEN
PRINT "abort marker ";BSTR$(M,16)
IF BVAL("D0",16)<=M AND M<=BVAL("D7",16) THEN ! RST0~7( restart
marker)
LET
rct=DRI ! set counter
CALL
reset0 ! Restart
ELSE
EXIT
SUB ! others marker
END IF
ELSE
PRINT "file error. display fragment"
LET M=BVAL("D9",16) ! EOI
EXIT SUB
END IF
END IF
NEXT U09
NEXT V09
IF 0< EOB THEN PRINT "EOBn over frame";EOB !!!
END SUB
SUB MCUxx11
!---read MCU
FOR P=0 TO CMO
IF 0<=HDC(P) OR 0<=HAC(P) THEN
FOR V0=V09 TO V09+8*MV(P)-1 STEP 8
FOR U0=U09 TO U09+8*MH(P)-1 STEP 8
WHEN EXCEPTION IN
IF
EOB=0 THEN CALL R_BLK0 ELSE LET EOB=EOB-1
USE
LET ext=EXTYPE
EXIT SUB
END WHEN
!---extend bitmap
IF 0< Ah AND 0< Se_ THEN
FOR i=A_ TO Se_
IF D2(U0+U(i),V0+V(i),P)<>0 THEN
LET
L_=1
WHEN
EXCEPTION IN
CALL DEC1_EX
USE
LET ext=EXTYPE
EXIT SUB
END
WHEN
LET
V_=SGN(D2(U0+U(i),V0+V(i),P))*V_*2^Al
LET
D2(U0+U(i),V0+V(i),P)=D2(U0+U(i),V0+V(i),P) +V_
END IF
NEXT i
LET A_=Ss_
END IF
!---
NEXT U0
NEXT V0
END IF
NEXT P
END SUB
!------
SUB R_BLK0
IF Ss_=0 THEN
!---D.C.part
LET debug$="DC.huffman" !!!
IF Ah=0 THEN !-----baseline.progSS.progSA(1st.scan).
LET J=HDC(P) !huffman D.C.table selection P( 0=Y 1=Cb 2=Cr)
CALL DEC1_NS
LET EL=V_ !extent length
!---D.C.extent
LET debug$="DC.huffman extend" !!!
IF 0< EL THEN
LET L_=EL
CALL
DEC1_EX !keep EL, V_=extent value( length EL bits)
LET
W=2^(EL-1) !minimum
in EL bits length
IF V_< W THEN LET V_=V_-(W*2-1) !restore signed value
LET
B2(P)=B2(P)+V_*2^Al !point
transform, integrate to D.C.
END IF
LET D2(U0+U(0),V0+V(0),P)=B2(P)
ELSE !-----progSA(2st.scan).
LET L_=1
CALL DEC1_EX
LET V_=SGN(D2(U0+U(0),V0+V(0),P))*V_
LET D2(U0+U(0),V0+V(0),P)=D2(U0+U(0),V0+V(0),P) +V_*2^Al
END IF
LET Sa_=1
ELSE
LET Sa_=Ss_
END IF
!---A.C.parts
IF Se_=0 THEN EXIT SUB !band Ss_~Se_
LET
J=HAC(P) !huffman
A.C.table selection P( 0=Y 1=Cb 2=Cr)
LET debug$="AC.huffman"
FOR A_=Sa_ TO Se_
CALL DEC1_NS
LET EL=MOD(V_,16) !extent length
LET RL= IP(V_/16) !run length
!---
IF RL<=14 AND EL=0 THEN !End Of Block(00). End Of Band(10,20,,E0)
!---EOBn extend
LET debug$="eobn extend"& STR$(RL)
IF 0< RL THEN
LET
L_=RL !extend=
run_length
CALL
DEC1_EX !keep RL, V_=run value(
length RL bits)
LET EOB=V_+2^RL-1 !RL= End Of Band(10,20,,E0) run length
END IF
EXIT SUB
!---
END IF
!---RL=(0~15)EL=(1~10), RL=(15)EL=(0)
LET debug$="AC.huffman extend" !!!
IF Ah=0 THEN !-----baseline.progSS.progSA(1st.scan).
LET
A_=A_+RL !skip
zero_run_length 0~15
!---A.C.extent
IF 0< EL THEN !ZRL(16) only skip
LET L_=EL
CALL
DEC1_EX !keep EL, V_=extent value( length EL
bits)
LET
w=2^(EL-1) !minimum
in EL bits length
IF V_< w THEN LET V_=V_-(w*2-1) !restore signed value
!---
LET V_=V_*2^Al !point transform
LET D2(U0+U(A_),V0+V(A_),P)=V_
END IF
ELSE !-----progSA(2st.scan).
IF 0< EL THEN !ZRL(16) only skip
LET L_=EL
CALL
DEC1_EX !keep EL, V_=extent value( length EL
bits)
IF EL<>1 THEN PRINT "AC.2nd.=";EL;V_ !!!
LET V01=V_
END IF
FOR i=A_ TO Se_
IF D2(U0+U(i),V0+V(i),P)<>0 THEN !zz(k)=xxx_1?/0?
LET L_=1
CALL DEC1_EX
LET V_=SGN(D2(U0+U(i),V0+V(i),P))*V_
LET D2(U0+U(i),V0+V(i),P)=D2(U0+U(i),V0+V(i),P) +V_*2^Al
ELSEIF
RL=0
THEN !zz(k)=000_V01
EXIT FOR
ELSE !zz(k)=000_0 ,zero
run
LET RL=RL-1
END IF
NEXT i
IF 0< EL THEN !ZRL(16) skip
IF V01=0 THEN LET V01=-1
LET D2(U0+U(i),V0+V(i),P)=V01*2^Al
END IF
LET A_=i
END IF
NEXT A_
END SUB
SUB DEC1_NS
DO
IF BC< BST THEN CALL DEC1_IN
LET W=IP(Hx) ! bits width BST
!----
LET W=A(NA+W,J)
IF 32768<=W THEN EXIT DO
LET
NA=W
! nest adr. W=0 table end
LET BC=BC-BST
LET Hx=MOD(Hx*SHb,SHb)
LOOP
LET
NA=0 !
DU0L LLLL VVVV VVVV
LET L_=MOD(IP(W/256),128) ! U0L LLLL
LET
V_=MOD(W,256)
! VVVV VVVV
IF 16< L_ THEN PRINT "unused code" !BREAK !unused code ! LET V_=BVAL("8000",16)
!----
LET W=MOD(L_,BST)
IF 0< W THEN
LET BC=BC-W
LET Hx=MOD(Hx*2^W,SHb)
ELSE
LET BC=BC-BST
LET Hx=MOD(Hx*SHb,SHb)
END IF
END SUB
SUB DEC1_IN
CALL RED_D
LET W=ORD(D$)
IF W=255 THEN
CALL RED_D
LET M=ORD(D$)
IF M<>0 THEN LET w=1/0 ! EXTYPE=3001, ffxx marker, abnormally break
END IF
LET Hx=Hx+W*2^(BST-8-BC)
LET BC=BC+8
END SUB
!-------
SUB DEC1_EX
LET V_=0
DO
IF L_< 1 THEN EXIT SUB
IF BC< L_ THEN CALL DEC1_IN
LET W=IP(Hx)
!----
IF BST>=L_ THEN EXIT DO
LET V_=V_*SHb+W
LET L_=L_-BST
LET BC=BC-BST
LET Hx=MOD(Hx*SHb,SHb)
LOOP
LET V_=V_*2^L_+IP(W*2^(L_-BST))
!----
LET BC=BC-L_
LET Hx=MOD(Hx*2^L_,SHb)
END SUB
!-------- IZZRL0 call here for display D2()
SUB MAIN65
PRINT "²èÁü¤Î½àÈ÷Ãæ¡¢";
CALL IDDCT8X8 ! D1()<-- iDCT<-- iDQT<-- D2()
!---
IF 1< MH(0) OR 1< MV(0) THEN ! Cb_Cr expand Blocks -->MCU scales
FOR V09=0 TO DV_-1 STEP 8*MV(0)
FOR U09=0 TO DU-1 STEP 8*MH(0)
!---MCU part.Cb.Cr
FOR V0=8*MV(0)-1 TO 0 STEP -1
FOR U0=8*MH(0)-1 TO 0 STEP -1
LET
D1(U09+U0,V09+V0,1)=D1(U09+IP(U0/MH(0)),V09+IP(V0/MV(0)),1)
LET
D1(U09+U0,V09+V0,2)=D1(U09+IP(U0/MH(0)),V09+IP(V0/MV(0)),2)
NEXT U0
NEXT V0
!---
NEXT U09
NEXT V09
END IF
! END SUB
!------ JPG ¿§¶õ´Ö ----------------------------
! | Y | | 0.2990 +0.5870 +0.1140 | | R |
! |B-Y| = |-0.1687 -0.3313 +0.5000 | | G |
! |R-Y| | 0.5000 -0.4187 -0.0813 | | B |
!
! | R | |
1
0 +1.40200 | | Y |
! | G | = | 1 -0.34414 -0.71414 | |B-Y|
! | B | |
1 +1.77200
0 | |R-Y|
!----------------------------------------------
! SUB DSPYbr
FOR V0=0 TO DY-1
FOR U0=0 TO DX-1
LET
w1=IP(D1(U0,V0,0) +1.40200*D1(U0,V0,2))
!R
LET w2=IP(D1(U0,V0,0) -0.34414*D1(U0,V0,1) -0.71414*D1(U0,V0,2)) !G
LET w3=IP(D1(U0,V0,0)
+1.77200*D1(U0,V0,1)) !B
IF w1< 0 THEN
LET w1=0
ELSEIF 255< w1 THEN
LET w1=255
END IF
IF w2< 0 THEN
LET w2=0
ELSEIF 255< w2 THEN
LET w2=255
END IF
IF w3< 0 THEN
LET w3=0
ELSEIF 255< w3 THEN
LET w3=255
END IF
LET D8(U0,V0)=w3*65536+w2*256+w1 !¡ÊµÕ¡ËBGR
NEXT U0
NEXT V0
LET w=TRUNCATE(MIN( (bmx-1)/DX,(bmy-1)/DY),1)
IF 1< w THEN LET w=IP(w)
IF 4< w THEN LET w=4
PRINT "ÉÁ²è¤ÎÇÜΨ=";w
MAT PLOT CELLS,IN 1,1; DX*w, DY*w :D8
END SUB
!========================
!inverse haffman Transform.
SUB IZZRL0
LET byt=0 !!!
CALL ROPEN ! FL$
!---
CALL R_BIN31(0) !A() B(i,J)L(i,J)<-- DH(), return at img.top
PRINT right$("000"& BSTR$(byt,16),4) !!!
PRINT "(";STR$(DX);"x";STR$(DY);
!---
MAT D8=ZER(DX-1,DY-1) !DSPYbr
LET i=8*MH(0) !MCU Y.Hsize
LET j=8*MV(0) !MCU Y.Vsize
LET DUM=CEIL(DX/i)*i !Uwidth=bound by MCU Y.Hsize
LET DVM=CEIL(DY/j)*j !Vwidth=bound by MCU Y.Vsize
MAT D1=ZER(DUM-1,DVM-1,2) !Y=D1(,,0) Cb=D1(,,1) Cr=D1(,,2)
MAT D2=ZER(DUM-1,DVM-1,2) !Y=D2(,,0) Cb=D2(,,1) Cr=D2(,,2)
LET MH_=MH(0)
LET MV_=MV(0)
LET DU
=DUM
!Uwidth=bound by MCU Y.Hsize
LET
DV_=DVM
!Vwidth=bound by MCU Y.Vsize
LET DU8=CEIL(DX/8)*8 !Uwidth=bound by block Y.Hsize
LET DV8=CEIL(DY/8)*8 !Vwidth=bound by block Y.Vsize
!---
PRINT "/ ";STR$(DU8);",";STR$(DV8);"/ ";STR$(DUM);",";STR$(DVM);")"
CALL frame
!---
CALL MAIN65
!---
IF 0< M THEN PRINT " (";STR$(DX);"x";STR$(DY);"/";STR$(U0);",";STR$(V0);") ";debug$;" abort by ";BSTR$(M,16) !!!
PRINT right$("000"& BSTR$(byt-2*SGN(M),16),4) !!!
CALL R_BIN31(M) ! return at img.top, or EOI
!---
DO WHILE M=BVAL("DA",16) !SOS
IF 0<=HAC(0) THEN
LET MV(0)=1
LET MH(0)=1
LET DU=DU8
LET DV_=DV8
END IF
CALL frame
LET MV(0)=MV_
LET MH(0)=MH_
LET DU=DUM
LET DV_=DVM
!---
IF Ss_<>Se_ AND M3(0)=M3(1) AND M3(1)=M3(2) THEN CALL MAIN65
!---
IF 0< M THEN PRINT "
(";STR$(DX);"x";STR$(DY);"/";STR$(U0);",";STR$(V0);") ";debug$;" abort
by ";BSTR$(M,16) !!!
PRINT right$("000"& BSTR$(byt-2*SGN(M),16),4) !!!
CALL R_BIN31(M) ! return at img.top
LOOP
CLOSE #1 ! FL$
END SUB
SUB reset0
LET B2(0)=0 !ROUND( YDC0/DQ(0,0,QS(0)) ) !prediction YDC.( 1st.reference level)
LET B2(1)=0 !prediction CbDC.
LET B2(2)=0 !prediction CrDC.
LET Hx=0 !bits stream input buffer 0~(7+8)bits, use fraction
LET BC=0 !stored bits in Hx
LET NA=0 !nest adr. in A()
LET EOB=0 !counter( end_of_band)
LET M=0
LET ext=0
END SUB
LET n=1987829
LET p=3^(n-1)
LET t=p-INT(p/n)*n
PRINT -1 !trace
PRINT t !¢«¢«¢«¢«¢«¡¡¤³¤³¤Ç¼Â¹Ô»þÆâÉô¥¨¥é¡¼¤¬È¯À¸¤¹¤ë
LET t=MOD(p,n)
PRINT -2 !trace
PRINT t
END
¼Â¹Ô·ë²Ì
-1
LET n=1987829
LET p=3^(n-1)
LET t=MOD(p,n)
PRINT -1 !trace
PRINT t !¢«¢«¢«¢«¢«¡¡É½¼¨¤µ¤ì¤ë¿ôÃͤ¬Àµ¤·¤¯¤Ê¤¤
LET t=p-INT(p/n)*n
PRINT -2 !trace
PRINT t !¢«¢«¢«¢«¢«¡¡¤³¤³¤Ç¼Â¹Ô»þÆâÉô¥¨¥é¡¼¤¬È¯À¸¤¹¤ë
END
¼Â¹Ô·ë²Ì
-1
836640
-2
!Rolling Cube 1 ¤Î²òË¡
!¡üÌäÂê
!£³¡ß£³¤ÎÈפˡ¢£¸¸Ä¤Î¤µ¤¤¤³¤í¤¬£±¤ÎÌܤ¬¾å¡Ê¾¤ÎÌܤâƱ¤¸¸þ¤¡Ë¤ÇÇÛÃÖ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
!¶õ¤¤¤Æ¤¤¤ë¥Þ¥¹¤Ëž¤¬¤·¤Æ¡¢¤¹¤Ù¤Æ¤ÎÌܤ¬£¶¤Ë¤Ê¤ë¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£
LET t0=TIME
PUBLIC NUMERIC xSIZE,ySIZE !ÈפÎÂ礤µ
LET xSIZE=3
LET ySIZE=3
!¡ü¤µ¤¤¤³¤í¤ÎÈ×¾å¤ÎÇÛÃÖ¤òÊѹ¹¤¹¤ë¾ì¹ç
PUBLIC NUMERIC M(10,10) !¤µ¤¤¤³¤í¤ÎÇÛÃÖ¡¡¢¨¿ô»ú¤ÏÈֹ桢£°¤Ï¶õ¤
MAT M=ZER(ySIZE+2,xSIZE+2)
DATA -1,-1,-1,-1,-1 !-1:ÊÉ¡¡¢¨ÈÖʼ
DATA -1, 1, 2, 3,-1 !¢«¢«¢«¢«¢« ¢¨
DATA -1, 4, 0, 5,-1
DATA -1, 6, 7, 8,-1
DATA -1,-1,-1,-1,-1
MAT READ M
LET SY=3 !¶õÇò¤Î°ÌÃÖ¡¡¢¨ÈÖʼ¤ò¹Íθ
LET SX=3
!¡ü¼ê¿ô¤Î¾å¸Â¤òÊѹ¹¤¹¤ë¾ì¹ç
PUBLIC NUMERIC LIM !¼ê¿ô¤Î¾å¸Â¡¡¢ªºÇ¾¯¼ê¿ô
LET LIM=49 !¢«¢«¢«¢«¢« ¢¨
!Ÿ³«¿Þ¤ÎÇÛÃÖ¤ÈÌÌÈÖ¹æ¡ÊÇÛÎóÊÑ¿ôT1¡ÁT8¤Îź¤¨»ú¤ËÂбþ¡Ë¤È¤Î´Ø·¸
!¡¡¢¢¡¡¡¡¡¡¡¡¸å¡¡¡¡¡¡¡¡£±
!¢¢¢¢¢¢¢¢¡¡º¸¾å±¦²¼¡¡£²£³£´£µ
!¡¡¢¢¡¡¡¡¡¡¡¡Àµ¡¡¡¡¡¡¡¡£¶
PUBLIC NUMERIC T1(6),T2(6),T3(6),T4(6),T5(6),T6(6),T7(6),T8(6) !£¸¸Ä¤Î¤µ¤¤¤³¤í
DATA 5 !ÌܤÎÇÛÃÖ¡¡¢¨Å¸³«¿Þ»²¾È
DATA 4,1,3,6
DATA 2
MAT READ T1
DATA 5
DATA 4,6,3,1
DATA 2
MAT READ T2
DATA 5
DATA 4,1,3,6
DATA 2
MAT READ T3
DATA 5
DATA 4,6,3,1
DATA 2
MAT READ T4
DATA 5
DATA 4,6,3,1
DATA 2
MAT READ T5
DATA 5
DATA 4,1,3,6
DATA 2
MAT READ T6
DATA 5
DATA 4,6,3,1
DATA 2
MAT READ T7
DATA 5
DATA 4,1,3,6
DATA 2
MAT READ T8
PUBLIC SUB rolling
EXTERNAL SUB rolling(i,T()) !¤µ¤¤¤³¤í¤ò²óž¤µ¤»¤ë
DIM TT(6) !ºî¶ÈÍÑ
SELECT CASE i !¢¨DX(),DY()»²¾È
CASE 0
CALL PermMultiply(T,L,TT) !¢¨¤µ¤¤¤³¤í¤Ë¤È¤Ã¤Æ¤ÏµÕ¤È¤Ê¤ë
CASE 1
CALL PermMultiply(T,D,TT)
CASE 2
CALL PermMultiply(T,R,TT)
CASE 3
CALL PermMultiply(T,U,TT)
CASE ELSE
END SELECT
MAT T=TT
END SUB
!---------- ¢¬¢¬¢¬¢¬¢¬ ----------
PUBLIC NUMERIC DX(4),DY(4) !£´¶á˵¡¡¢¨È¿»þ·×¤Þ¤ï¤ê¤ÎÏ¢ÈÖ¡¡±¦:0¡¢¾å:1¡¢º¸:2¡¢²¼:3
DATA 1, 0,-1,0
DATA 0,-1, 0,1
MAT READ DX
MAT READ DY
END MODULE
!͸ú¿ô»ú¡Ê͸ú·å¿ô¡Ë¤Î·×»»ÊýË¡
!»²¹Í¥µ¥¤¥È¡¡http://ja.wikipedia.org/wiki/%E6%9C%89%E5%8A%B9%E6%95%B0%E5%AD%97
!»²¹Í¥µ¥¤¥È¡¡http://hp.vector.co.jp/authors/VA008683/QA_JISROUND.htm
FUNCTION ROUND10(x,n) !ºÇ¶áÀܶö¿ô¤Ø¤Î´Ý¤á¤ÎÊýË¡¤Ç¡¢x¤ò¾®¿ôÅÀ°Ê²¼n·å¤Ë´Ý¤á¤ë
LET x=x*10^n
IF MOD(x,1)<0.5 THEN
LET x=INT(x)
ELSEIF MOD(x,1)>0.5 THEN
LET x=CEIL(x)
ELSEIF MOD(INT(x),2)=0 THEN
LET x=INT(x)
ELSE
LET x=CEIL(x)
END IF
LET ROUND10=x/10^n
END FUNCTION
!¾®¿ôÅÀ°Ê²¼·å¿ô¸ÇÄê FIX(¿ôÃÍ,·å¿ô)
DEF FIX(x,n)=ROUND10(x,n)
!DEF FIX(x,n)=ROUND(x,n) !=INT(x*10^n+0.5)/10^n
!DEF FIX(x,n)=TRUNCATE(x,n) !=IP(x*10^n)/10^n
FUNCTION SCI(x,n) !͸ú·å¿ô»ØÄê SCI(¿ôÃÍ,·å¿ô)
LET m=0
IF x>1 THEN !##.#¤Ê¤é
DO UNTIL ABS(x)<1 !0.###·Á¼°¤Ø
LET x=x/10
LET m=m+1
LOOP
LET SCI=FIX(x,n)*10^m !¢¨JIS Z8401¡Ø¿ôÃͤδݤáÊý¡Ù¡¢Ã±½ã¤Ê»Í¼Î¸ÞÆþ¡¢ÀڼΤƤʤÉ
ELSE !0.00###¤Ê¤é
DO UNTIL ABS(x)>=1 !#.##·Á¼°¤Ø
LET x=x*10
LET m=m+1
LOOP
LET SCI=FIX(x,n-1)/10^m
END IF
!PRINT "x=";x; "m=";m !debug
END FUNCTION
!Îã¡¡12.3+50*0.650
PRINT FIX(12.3 + SCI(50*0.650,2), 0) !2=50¤Î͸ú·å¿ô¡¢0=50¤Î͸ú·å°ÌÃÖ
PRINT 12.3+50*0.650 !¤Ù¤¿
PRINT
!Îã¡¡( 2.234 * 5.67815 + 100.9049 ) * 4.60
PRINT SCI(FIX( SCI(2.234*5.67815,4) + 100.9049, 2) * 4.60, 3) !Ëè²ó´Ý¤á¤ë¤ÈÀºÅÙ¤¬Íî¤Á¤ë¾ì¹ç¤¬¤¢¤ë
PRINT SCI(FIX( SCI(2.234*5.67815,5) + 100.9049, 3) * 4.60, 3) !¤½¤³¤Ç͸ú¿ô»ú¡Ü£±·å¤Ç·×»»¤ò¿Ê¤á¤ë
PRINT ( 2.234 * 5.67815 + 100.9049 ) * 4.60
PRINT
!Îã¡¡£¸·å´Ø¿ôÅÅÂî¤Î¥·¥ß¥å¥ì¡¼¥·¥ç¥ó¡¡¢¨£È£Ð¤ÏJIS´Ý¤á¡¢¥·¥ã¡¼¥×¤È¥«¥·¥ª¤Ï»Í¼Î¸ÞÆþ
PRINT SCI(2+5E-8,8) !JIS Z8401¡Ø¿ôÃͤδݤáÊý¡Ù 2.0000000
PRINT SCI(2+5.1E-8,8) !2.0000001
PRINT SCI(5.0000002*5.0000003,8) !25.000003
PRINT 5.0000002*5.0000003
PRINT SCI(5.0000001*5,8) !25.000000¡¡¢¨2¿Ê¥â¡¼¥É¤Ç¤ÏNG
PRINT 5.0000001*5
END
SET LINE COLOR "black"
FOR tt=0 TO 4100 STEP 5 !¥«¥¦¥ó¥¿ÊÑ¿ô¤ÏÀ°¿ô·¿¤È¤¹¤ë¡¡¢«¢«¢«¢«
LET t=tt/100 !¼ÂºÝ¤ÎÃͤ˴¹»»¤¹¤ë¡¡¢«¢«¢«¢«
LET x=r*COS(w*t)
LET y=r*SIN(w*t)
LET z=vz*t
CALL henkan(x,y,z,xrad,yrad,zrad,x3,y3,z3)
PLOT LINES:x3_,y3_;x3,y3
LET x3_=x3
LET y3_=y3
LET cnt=MOD(tt,40) !¢«¢«¢«¢«
IF cnt=0 THEN
LET x=0
LET y=0
CALL henkan(x,y,z,xrad,yrad,zrad,x0_,y0_,z0_)
PLOT LINES:x0_,y0_;x3_,y3_
PLOT POINTS:x3_,y3_
END IF
NEXT tt !¢«¢«¢«¢«
OPTION ARITHMETIC NATIVE
OPTION BASE 0
DIM D8(500,500)
!
SET VIEWPORT 0, 0.4, 0.6, 1
CALL sample(DX$,DY$)
LET DX=VAL(DX$)
LET DY=VAL(DY$)
MAT D8=ZER(DX,DY)
!
SET VIEWPORT 0, 1, 0, 1
SET WINDOW 0, 500, 500, 0
!
! SET COLOR MODE "NATIVE" ! ¢«¤³¤ì¤òÆþ¤ì¤ë¤ÈÀµ¾ï¤Ë¥³¥Ô¡¼¤µ¤ì¤ë¡£
!
ASK PIXEL ARRAY (0,0) D8
MAT PLOT CELLS,IN 250,250; 450,450: D8
!
!main00
! (
! )
END
EXTERNAL SUB sample(DX$,DY$)
! ¥Þ¥ó¥Ç¥ë¥Ö¥í¡¼¡ÊComplex\mandelbm.bas ¤ÎÃ忧²þÊÑ¡Ë
OPTION ARITHMETIC COMPLEX
SET COLOR MODE "REGULAR"
SET POINT STYLE 1
FOR n=0 TO 50
SET COLOR MIX( n) 0
,0 ,n/51 !BLACK =< < BLUE
SET COLOR MIX( 51+n) 0 ,n/51 ,1 !BLUE =< < CYAN
SET COLOR MIX(102+n) 0 ,1 ,1-n/51 !CYAN =< < GREEN
SET COLOR MIX(153+n) n/51,1 ,0 !GREEN =< < YELLOW
SET COLOR MIX(204+n) 1 ,1-n/51,0 !YELLOW =< < RED
NEXT n
LET XL=-2
LET XR=.8
LET w1=XR-XL
LET w2=w1/2
SET WINDOW XL, XR,-w2,w2
ASK PIXEL SIZE(XL,-w2; XR,w2) px,py
!
FOR x=XL TO XR STEP w1/(px-1)
FOR y=-w2-.49*w1/(py-1) TO w2 STEP w1/(py-1) !¸Î°Õ¤Ë(x,0)¤òÉÁÅÀ¤Î´Ö¤Ë¶´¤à¡£
LET z=0
FOR n=1 TO 255
LET z=z^2+COMPLEX(x,y)
IF 2< ABS(z) THEN
IF
n< 64 THEN SET POINT COLOR n*4 ELSE SET POINT COLOR 255
PLOT POINTS :x,y !¾å²¼¤ÎÂоݥץí¥Ã¥È¤ò¤·¤Ê¤¤¡£
EXIT FOR
END IF
NEXT n
NEXT y
NEXT x
LET DX$=STR$(px-1)
LET DY$=STR$(py-1)
END SUB
!========================
SUB W_BIN31
!---SOI
CALL WRT_H("FFD8")
!---APP0
CALL WRT_H("FFE0")
CALL WRT_W( 2+14) !size
CALL WRT_M("JFIF"& CHR$(0))
CALL WRT_H("0101") !ver 1.1
CALL WRT_D(1) !0=none 1=dpi 2=dpcm
CALL WRT_W(72) !Xd 72 ¥¢¥¹¥Ú¥¯¥ÈÈæ¡¡IE6(no) imaging(ok)
CALL WRT_W(72) !Yd 72 ¥¢¥¹¥Ú¥¯¥ÈÈæ
CALL WRT_D(0) !Xt 0
CALL WRT_D(0) !Yt 0
!---DQT.Y.C
CALL WRT_H("FFDB")
LET W=2 !start size
FOR J=0 TO CMO/2 !CMO=0(mono.) CMO=2(color)
LET W=W+1+64 !+ID +QT
NEXT J
CALL WRT_W( W) !size
FOR J=0 TO CMO/2 ! CMO=0(mono.) CMO=2(color)
CALL WRT_D(J) !J= (0)Y.DQ (1)C.DQ
FOR I=0 TO 63
CALL WRT_D( DQ(U(i),V(i),J) )
NEXT I
NEXT J
!---SOF0
CALL WRT_H("FFC0")
IF CMO=0 THEN CALL WRT_W( 11) ELSE CALL WRT_W( 17) !size
CALL WRT_D( 8) !8bit at RGB
CALL WRT_W( DY) !V.pixels
CALL WRT_W( DX) !H.pixels
IF CMO=0 THEN
CALL WRT_H("01") !1 items
CALL WRT_H("011100") !Y MCU(H:V) DQT
ELSE
CALL WRT_H("03") !3 items
CALL WRT_H("01"&
STR$(MH(0))& STR$(MV(0))& "0"& STR$(QS(0)))
!Y MCU(H:V) DQT
CALL WRT_H("02"& STR$(MH(1))& STR$(MV(1))& "0"& STR$(QS(1))) !Cb - -
CALL WRT_H("03"& STR$(MH(2))& STR$(MV(2))& "0"& STR$(QS(2))) !Cr - -
END IF
!---DHT
CALL WRT_H("FFC4")
LET W=2 !start size
FOR J=0 TO CMO+1 !CMO=0(mono.) CMO=2(color)
LET W=W+1+16+DH(0,J) !+ID +HT +VT
NEXT J
CALL WRT_W( W) !size
FOR J=0 TO
CMO+1
!CMO=0(mono.) CMO=2(color)
CALL WRT_D( 16*MOD(J,2)+IP(J/2) ) ! 00h=YDC 10h=YAC 01h=CDC 11h=CAC
FOR I=1 TO
16
!(J) 0 =YDC 1 =YAC 2 =CDC 3 =CAC
CALL WRT_D( DH(I,J))
NEXT I
FOR I=0 TO DH(0,J)-1
CALL WRT_D( DV(I,J))
NEXT I
NEXT J
!---SOS
CALL WRT_H("FFDA")
IF CMO=0 THEN
CALL WRT_W(8) !size
CALL WRT_D(1) !1 items
CALL WRT_H("0100") !No. Y.HDC/HAC
ELSE
CALL WRT_W(12) !size
CALL WRT_D( 3) !3 items
CALL WRT_H("0100") !No. Y.HDC/HAC
CALL WRT_H("0211") !No. Cb.HDC/HAC
CALL WRT_H("0311") !No. Cr.HDC/HAC
END IF
CALL WRT_H("003F00") !band 0~63, AhAl=00
END SUB
!----------------
!open write binary
SUB WOPEN
OPEN #1:NAME FL$
ERASE #1
END SUB
!sequential write byte
SUB WRT_D( D)
PRINT #1 :CHR$(D);
LET byt=byt+1 !!!
END SUB
!sequential write word
SUB WRT_W( w)
PRINT #1 :CHR$(IP(w/256));CHR$(MOD(w,256));
LET byt=byt+2 !!!
END SUB
!sequential write binary massage W$
SUB WRT_M( w$)
FOR w=1 TO LEN(w$)
PRINT #1 :MID$(w$,w,1);
NEXT w
LET byt=byt+w-1 !!!
END SUB
!sequential write binary hex.massage w$
SUB WRT_H( w$)
FOR w=1 TO LEN(w$) STEP 2
PRINT #1 :CHR$(BVAL(MID$(w$,w,2),16));
NEXT w
LET byt=byt+LEN(w$)/2 !!!
END SUB
!=====================
! print huffman_table
SUB list_HT( m$,J)
PRINT m$;" ÉÑÅÙ ºÂɸ bit ¥³¡¼¥É(";
IF MOD(B(256,J),2)=1 THEN PRINT "ºÂɸ½ç)" ELSE PRINT "À¸À®½ç¡¢ÉÑÅٹ߽ç)"
LET sum=0
FOR i=0 TO 255
IF L(i,J)<>0 THEN
IF MOD(B(256,J),2)=1 THEN ! 1=Sort_value. Encorder
LET V_=i
LET
w$=" "& RIGHT$(" "&
STR$(SV(i,J)),4)& " " ! times
LET sum=sum+L(i,J)*SV(i,J)
ELSE !
0=Sort_length. Decorder
LET V_=DV(i,J)
LET
w$=" "& RIGHT$(" "&
STR$(S_(i,J)),4)& " " ! times
LET sum=sum+L(i,J)*S_(i,J)
END IF
LET w$=w$& RIGHT$("0"& BSTR$(V_,16),2)& " " ! value
LET w$=w$& RIGHT$(" "& STR$(L(i,J)),2)& " " ! length
!--- huffman code
LET H_=B(i,J) ! code
LET L_=L(i,J) ! length
!--- bit_pattern
LET w$=w$& left$(right$("0000000"& BSTR$(H_,2),16),L_)
PRINT w$
END IF
NEXT i
PRINT " ¹ç·×( ÉÑÅÙ * bit)=";sum
END SUB
END
EXTERNAL SUB sample(DX$,DY$)
! ¥Þ¥ó¥Ç¥ë¥Ö¥í¡¼¡ÊComplex\mandelbm.bas ¤ÎÃ忧²þÊÑ¡Ë
OPTION ARITHMETIC COMPLEX
SET COLOR MODE "REGULAR"
SET POINT STYLE 1
FOR n=1 TO 51
SET COLOR MIX( n) 0
,0 ,n/51 !BLACK < < BLUE
SET COLOR MIX( 51+n) 0
,n/51 ,1 !BLUE <
< CYAN
SET COLOR MIX(102+n) 0 ,1 ,1-n/51 !CYAN < < GREEN
SET COLOR MIX(153+n) n/51,1 ,0 !GREEN < < YELLOW
SET COLOR MIX(204+n) 1 ,1-n/51,n/51 !YELLOW< < MAGENTA
NEXT n
LET XL=-2
LET XR=.8
LET w1=XR-XL
LET w2=w1/2
SET WINDOW XL, XR,-w2,w2
ASK PIXEL SIZE(XL,-w2; XR,w2) px,py
!
FOR x=XL TO XR+1e-6 STEP w1/(px-1)
FOR y=-w2-.49*w1/(py-1) TO w2 STEP w1/(py-1) !¸Î°Õ¤Ë(x,0)¤òÉÁÅÀ¤Î´Ö¤Ë¶´¤à¡£
LET z=0
FOR n=1 TO 255
LET z=z^2+COMPLEX(x,y)
IF 2< ABS(z) THEN
IF
n< 64 THEN SET POINT COLOR n*4 ELSE SET POINT COLOR 253
PLOT POINTS :x,y !¾å²¼¤ÎÂоݥץí¥Ã¥È¤ò¤·¤Ê¤¤¡£
EXIT FOR
END IF
NEXT n
NEXT y
NEXT x
LET DX$=STR$(px)
LET DY$=STR$(py)
END SUB
!-------------------
! make huffman tree
SUB TREE3
MAT Tr=ZER
FOR i=0 TO SE
LET F_(i)=S_(i,P)
NEXT i
!---minimum2
DO
LET w=1e8
FOR i=0 TO SE
IF F_(i)< w THEN
LET w=F_(i)
LET Ad1=i ! minimum1
END IF
NEXT i
LET w=1e8
FOR i=0 TO SE
IF F_(i)< w AND i<>Ad1 THEN
LET w=F_(i)
LET Ad2=i ! minimum2
END IF
NEXT i
IF w=1e8 THEN EXIT DO
IF Ad1>Ad2 THEN swap Ad1,Ad2
!---
LET F_(Ad1)=F_(Ad1)+F_(Ad2)
LET F_(Ad2)=1e9
!---
FOR Le1=16 TO 1 STEP -1
IF Tr(Le1,Ad1,1)>0 OR Tr(Le1,Ad1,3)>0 THEN EXIT FOR
NEXT Le1
FOR Le2=16 TO 1 STEP -1
IF Tr(Le2,Ad2,1)>0 OR Tr(Le2,Ad2,3)>0 THEN EXIT FOR
NEXT Le2
LET Le0=MAX( Le1,Le2 )+1
!---
LET Tr(Le0,Ad1,0)=Le1
LET Tr(Le0,Ad1,1)=Ad1
LET Tr(Le0,Ad1,2)=Le2
LET Tr(Le0,Ad1,3)=Ad2
LOOP
!---make DH()
LET DH(0,P)=SE+1
LET k=0
CALL bitl(Le0,Ad1)
FOR Ad=0 TO SE
LET DH(Tr(0,Ad,1),P)=DH(Tr(0,Ad,1),P)+1
NEXT Ad
END SUB
SUB bitl(Le,Ad)
IF 0< Le THEN
LET k=k+1
CALL bitl( Tr(Le,Ad,0), Tr(Le,Ad,1) )
CALL bitl( Tr(Le,Ad,2), Tr(Le,Ad,3) )
LET k=k-1
ELSE
LET Tr(Le,Ad,1)=k
END IF
END SUB
!-------------------
! Quick Sort S_()
SUB Qsort(L,R) ! ¹ß½ç¤Ë¥»¥Ã¥È¡£
local i,j
LET i=L
LET j=R
LET Tx=S_(IP((L+R)/2),P)
DO
DO WHILE S_(i,P) >Tx ! ¹ß½ç¡ä¡¢¾º½ç¡ã
LET i=i+1
LOOP
DO WHILE Tx >S_(j,P) ! ¹ß½ç¡ä¡¢¾º½ç¡ã
LET j=j-1
LOOP
IF j< i THEN EXIT DO ! Åù¹æÉÕ j<=i ¤Ï¡¢Ë½Áö¡£
SWAP S_(i,P),S_(j,P)
SWAP DV(i,P),DV(j,P)
LET i=i+1
LET j=j-1
LOOP UNTIL j< i ! Åù¹æÉÕ j<=i ¤Ï¡¢Ä㮡£
IF L< j THEN CALL Qsort(L,j)
IF i< R THEN CALL Qsort(i,R)
END SUB
!===================================
! make encorder table B()L()<-- DH()
SUB MAKE_H2
MAT L=ZER
FOR J=0 TO CMO+1
LET I=0 ! ¥³¡¼¥ÉÀ¸À® ½çÈÖ(û¤¤½ç)
LET Hx=0
LET Tx=BVAL("8000",16)
FOR L_=1 TO 16
FOR N=1 TO DH(L_,J)
LET V_=DV(I,J) ! ºÂɸDV(ÉÑÅٹ߽ç)
LET L(V_,J)=L_
LET B(V_,J)=Hx ! ¥³¡¼¥É(ºÂɸV_)
LET I=I+1
LET Hx=Hx+Tx
NEXT N
LET Tx=Tx/2
NEXT L_
LET B(256,J)=1
NEXT J
END SUB
!==============================
!Fast Discrete Cosin Transform.( M=8x8, DCT-2 )
SUB DDCT8X8
FOR P=0 TO CMO ! (0=Y,1=Cb,2=Cr)
FOR V0=0 TO DV_-1 STEP 8*MV(0)/MV(P)
FOR U0=0 TO DU-1 STEP 8*MH(0)/MH(P)
FOR Y_=0 TO 7
LET w=Y_*MV(0) !sampling pt.Y
FOR X_=0 TO 7 !level shift, sampling CbCr from MCU
IF
P=0 THEN LET X(X_)=D2(U0+X_,V0+Y_,P)-128 ELSE LET
X(X_)=D2(U0+X_*MH(0),V0+w,P)
NEXT X_
CALL WANG
FOR U_=0 TO 7
LET T(U_,Y_)=X(U_)
NEXT U_
NEXT Y_
FOR U_=0 TO 7
FOR Y_=0 TO 7
LET X(Y_)=T(U_,Y_)
NEXT Y_
CALL WANG
FOR V_=0 TO 7
LET
D2(U0+U_,V0+V_,P)=ROUND( X(V_)/DQ(U_,V_,QS(P)) ) ! Quantization
NEXT V_
NEXT U_
NEXT U0
NEXT V0
NEXT P
END SUB
!=============================
!Fast Discrete Cosin Transform
!Wang.( M=8, DCT-2 )
SUB WANG
LET XO(0)=X(0)+X(7)
LET XO(1)=X(1)+X(6)
LET XO(2)=X(2)+X(5)
LET XO(3)=X(3)+X(4)
LET XO(4)=X(3)-X(4)
LET XO(5)=X(2)-X(5)
LET XO(6)=X(1)-X(6)
LET XO(7)=X(0)-X(7)
!
LET X(0)=XO(0)+XO(3)
LET X(1)=XO(1)+XO(2)
LET X(2)=XO(1)-XO(2)
LET X(3)=XO(0)-XO(3)
LET X(4)=XO(7)*SQR(2)
LET X(5)=XO(6)-XO(5)
LET X(6)=XO(6)+XO(5)
LET X(7)=XO(4)*SQR(2)
!
LET XO(0)=(COS(PI/4)*X(0)+COS(PI/4)*X(1))
LET XO(1)=(COS(PI/4)*X(0)-COS(PI/4)*X(1)) !fin 0(0),1(4)
LET XO(2)=(COS(PI/8)*X(3)+SIN(PI/8)*X(2))
LET XO(3)=(COS(PI*3/8)*X(3)-SIN(PI*3/8)*X(2)) !fin 2(2),3(6)
LET XO(4)=X(4)
LET XO(5)=X(6)
LET XO(6)=X(5)
LET XO(7)=X(7)
!
LET X(4)=XO(4)+XO(5)
LET X(5)=XO(4)-XO(5)
LET X(6)=-XO(6)+XO(7)
LET X(7)=XO(6)+XO(7)
!
LET XO(4)=(COS(PI/16)*X(4)+SIN(PI/16)*X(7))
LET XO(5)=(COS(PI*5/16)*X(5)+SIN(PI*5/16)*X(6))
LET XO(6)=(SIN(PI*5/16)*X(5)-COS(PI*5/16)*X(6))
LET XO(7)=(SIN(PI/16)*X(4)-COS(PI/16)*X(7))
!
LET X(0)=SQR(2/8)*XO(0)
LET X(4)=SQR(2/8)*XO(1)
LET X(2)=SQR(2/8)*XO(2)
LET X(6)=SQR(2/8)*XO(3)
LET X(1)=SQR(1/8)*XO(4)
LET X(5)=SQR(1/8)*XO(5)
LET X(3)=SQR(1/8)*XO(6)
LET X(7)=SQR(1/8)*XO(7)
END SUB
! haffman Transform. main
SUB ZZRL0
! ---pass-1 analize frequency SV(nnnn,ssss) -->DV( ,J) DH( ,J)
IF 0< MHT OR DH(0,0)=0 THEN CALL ZFRE0
!---pass-2
CALL MAKE_H2 ! huffman code=B(V,J) len.=L(V,J) <-- DH( ,J) DV( ,J)
!---
LET byt=0 !!!
CALL WOPEN
CALL W_BIN31
!---
LET Hw=0 !bits stream buffer
LET BC=0 !bits in Hw
!---
LET B2(0)=0 ! Y.DC( start prediction)
LET B2(1)=0 ! Cb.DC
LET B2(2)=0 ! Cr.DC
!---
FOR V09=0 TO DV_-1 STEP 8*MV(0)
FOR U09=0 TO DU-1 STEP 8*MH(0)
!---MCU
FOR P=0 TO CMO !( 0=Y 1=Cb 2=Cr)
FOR V0=V09 TO V09+8*MV(P)-1 STEP 8
FOR U0=U09 TO U09+8*MH(P)-1 STEP 8
CALL W_BLK0
NEXT U0
NEXT V0
NEXT P
!---
NEXT U09
NEXT V09
CALL W_FLUSH
!---EOI
CALL WRT_H("FFD9")
CLOSE #1
PRINT "byte size:";byt
END SUB
!------
SUB F_BLK0
LET J=2*SGN(P) ! ( 0=Y 1=Cb 2=Cr)
!---D.C.part
LET W=D2(U0+U(0),V0+V(0),P)
LET SY=W-B2(P)
LET B2(P)=W ! previous of D.C.difference
IF SY<>0 THEN LET SS=LEN(BSTR$(ABS( SY),2)) ELSE LET SS=0 ! bit_length
LET SV(SS,J)=SV(SS,J)+1
!---A.C.parts
FOR AE=63 TO 0 STEP -1
IF 0<>D2(U0+U(AE),V0+V(AE),P) THEN EXIT FOR
NEXT AE
!---
LET Z=0 !zero run counter
FOR A_=1 TO AE
LET SY=D2(U0+U(A_),V0+V(A_),P)
IF SY=0 AND Z< 15 THEN
LET Z=Z+1
ELSE
IF SY<>0 THEN LET SS=LEN(BSTR$(ABS(SY),2)) ELSE LET SS=0 ! bit_length
LET W=Z*16+SS
LET Z=0
LET SV(W,J+1)=SV(W,J+1)+1
END IF
NEXT A_
IF A_< 64 THEN LET SV(0,J+1)=SV(0,J+1)+1 !End Of Block
END SUB
SUB W_BLK0
LET J=2*SGN(P) ! ( 0=Y 1=Cb 2=Cr)
!---D.C.part absolute SY bits length
LET W=D2(U0+U(0),V0+V(0),P)
LET SY=W-B2(P)
LET B2(P)=W ! previous of D.C.difference
IF SY<>0 THEN LET SS=LEN(BSTR$(ABS( SY),2)) ELSE LET SS=0 ! bit_length
LET L_=L(SS,J)
LET Ww=B(SS,J)
CALL W_HUFF
!---D.C.extent
IF SS<>0 THEN
IF SY< 0 THEN LET SY=SY+2^SS-1 !add maxim. in same bit_length.
LET L_=SS
LET Ww=SY*2^(16-L_)
CALL W_HUFF
END IF
!---A.C.parts
FOR AE=63 TO 0 STEP -1
IF 0<>D2(U0+U(AE),V0+V(AE),P) THEN EXIT FOR
NEXT AE
!---
LET Z=0 !zero run counter
FOR A_=1 TO AE
LET SY=D2(U0+U(A_),V0+V(A_),P)
IF SY=0 AND Z< 15 THEN
LET Z=Z+1
ELSE
IF SY<>0 THEN LET SS=LEN(BSTR$(ABS(SY),2)) ELSE LET SS=0 ! bit_length
LET W=Z*16+SS
LET Z=0
LET L_=L(W,J+1)
LET Ww=B(W,J+1)
CALL W_HUFF
!---A.C.extent
IF SS<>0 THEN
IF
SY< 0 THEN LET SY=SY+2^SS-1 !add maxim. in same bit_length.
LET L_=SS
LET Ww=SY*2^(16-L_)
CALL W_HUFF
END IF
END IF
NEXT A_
IF A_< 64 THEN
LET L_=L(0,J+1)
LET Ww=B(0,J+1)
CALL W_HUFF !End Of Block
END IF
END SUB
!-----
!Ww¡§b15 ~0 º¸µÍ¤á ÆþÎÏ bit_stream. L_¡§bitĹ
SUB W_HUFF
LET Hw=Hw+Ww*2^(-BC-8)
LET BC=BC+L_
DO WHILE 8<=BC
CALL WRT_D( IP(Hw))
IF IP(Hw)=255 THEN CALL WRT_D( 0)
LET Hw=FP(Hw)*256
LET BC=BC-8
LOOP
END SUB
!flush bit buffer with byte_bound( fill"1"in blank)
SUB W_FLUSH
IF BC<>0 THEN
LET w=Hw +2^(8-BC)-1
CALL WRT_D( w)
IF w=255 THEN CALL WRT_D( 0)
END IF
END SUB
!=====================
!pre hafman Transform.
!sort frequency S_() of nnnnssss( zero_run_length data)
!make DH() DV()
SUB MAKE_DHT
MAT DH=ZER
!---debug monitor
PRINT "-----------------------------------------"
FOR J=0 TO CMO+1 ! CMO =0=mono =2=color
PRINT "Zero_Run_Length ÉÑÅÙɽ¡¡(¢ª)²èÁÇbitÉý0~15¡¢(¢)ľÁ°£°¿ô0~15"
PRINT W_$(J)
CALL msg00( SV, 0,255,J, 5) ! SV( 0~255, J)
PRINT "total=";Tx
NEXT J
PRINT
!---
FOR P=0 TO CMO+1 ! P(0~1=Y.DC~AC 2~3=C.DC~AC), CMO( 0=mono 2=color)
!--- make S_(,)DV(,)<-- SV(,)
LET SE=-1
FOR i=0 TO 255
IF SV(i,P)<>0 THEN
LET SE=SE+1
LET S_(SE,P)=SV(i,P)
LET DV(SE,P)=i
END IF
NEXT i
PRINT "===================================="
PRINT W_$(P)
PRINT "Zero Run Length ÉÑÅÙɽ¤òµÍ¤á¤¿¤â¤Î"
CALL msg00( S_, 0,SE,P, 5) ! S_(0~SE, P)
PRINT "ɽºÂɸ(0~F=ľÁ°£°¿ô¡§0~F=²èÁÇbitĹ)"
CALL msg0x( DV, 0,SE,P, 5) ! DV(0~SE, P)
!---
CALL Qsort(0,SE)
CALL TREE3
!---
PRINT
PRINT " Encoder DHT table"
PRINT " (¢ª)¥³¡¼¥ÉĹ1~16¤Î¡¢³Æ¸Ä¿ô"
CALL msg0x( DH, 1,16 ,P, 3) ! DH(1~16, P)
PRINT " ÉÑÅÙ½ç¤Î¡¢É½ºÂɸ(0~F=ľÁ°£°¿ô¡§0~F=²èÁÇbitĹ)"
CALL msg0x( DV, 0,Tx-1,P, 3) ! DV(0~Tx-1, P)
PRINT
NEXT P
END SUB
SUB msg00( M(,), S,E,J, w)
LET Tx=0
LET w$=""
FOR i=S TO E
LET Tx=Tx+M(i,J)
LET w$=w$& USING$( REPEAT$("#",w),M(i,J))
IF MOD(i-S,16)=15 THEN LET w$=w$& crlf$
NEXT i
IF MOD(i-S,16)=0 THEN PRINT w$; ELSE PRINT w$
END SUB
SUB msg0x( M(,), S,E,J, w)
LET Tx=0
LET w$=""
FOR i=S TO E
LET Tx=Tx+M(i,J)
LET w$=w$& REPEAT$(" ",w-2)& RIGHT$("0"& BSTR$(M(i,J),16),2)
IF MOD(i-S,16)=15 THEN LET w$=w$& crlf$
NEXT i
IF MOD(i-S,16)=0 THEN PRINT w$; ELSE PRINT w$
END SUB
OPTION ARITHMETIC NATIVE
OPTION BASE 0
OPTION CHARACTER byte
SET TEXT background "OPAQUE"
ASK BITMAP SIZE bmx,bmy
SET WINDOW 0,bmx, bmy,0
!
DIM D8(1000,1000) !sample picture
DIM D2(1000,1000,2) !Y=D2(,,0) Cb=D2(,,1) Cr=D2(,,2)
DIM MH(2),MV(2) !MCU.Ybr.H()V()
DIM HDC(2),HAC(2) !hT.table selection
DIM QS(2),CoID(255) !qT.table selection
!
DIM U(63),V(63) !zigzag
DIM DQ(7,7,3) !DQT
DIM DH(16,7),DV(255,7) !DHT
DIM B(255+1,7),L(255,7) !huffman.code & length ( MAKE_H2 )
DIM B2(2) !Ybr D.C.À®Ê¬ starting
DIM T(7,7),X(7),XO(7) !DDCT8X8
!
!---encorder
DIM SV(255,3) !ZFRE0 ÉÑÅÙSV( ºÂɸ)
DIM
S_(255,3) !MAKE_DHT
ÉÑÅÙSV( ºÂɸ)--> ÉÑÅÙS_( ¹ß½çNo.) ºÂɸDV( ¹ß½çNo.)
DIM F_(255),Tr(16,255,3) !TREE3
!---lister
LET crlf$=CHR$(13)& CHR$(10)
DIM W_$(7)
LET W_$(0)="Y.DC"
LET W_$(1)="Y.AC"
LET W_$(2)="C.DC"
LET W_$(3)="C.AC"
!
SET VIEWPORT 0,0.4,0.6,1
CALL sample(DX$,DY$) !¥µ¥ó¥×¥ë²èÁü¡£
LET DX=VAL(DX$)
LET DY=VAL(DY$)
MAT D8=ZER(DX-1,DY-1)
SET VIEWPORT 0, 1, 0, 1
SET WINDOW 0,bmx, bmy,0
SET COLOR MODE "NATIVE"
ASK PIXEL ARRAY (0,0) D8
! MAT PLOT CELLS,IN 250,250; 450,450: D8 ! check
!
LET CMO=2 !CMO=0(mono.) CMO=2(color)
LET SD=1 !encoder Î̻Ҳ½¥Æ¡¼¥Ö¥ëÄ´À° 1/SD
CALL DQTINI !DQ(,,0)~DQ(,,1)~{zigzag U()V()},MH(),MV()
LET DU =CEIL(DX/(8*MH(0)))*8*MH(0) !Uwidth= (8X8)*2 bound by MCU size
LET DV_=CEIL(DY/(8*MV(0)))*8*MV(0) !Vwidth= (8X8)*1
MAT D2=ZER(DU-1,DV_-1,2) !Y=D2(,,0) Cb=D2(,,1) Cr=D2(,,2)
!
CALL YbrRGB ! Ybr D2()<--RGB D8()
LET MHT=1 ! flag. uncondition making huff.table
CALL DDCT8X8 ! D2() -->DCT -->Quantization
CALL ZZRL0 ! encoder
!---
PRINT "-------------------------"
PRINT "Encoder huffman Code"
FOR J=0 TO CMO+1
CALL list_HT(W_$(J),J) ! value Sort !H2.LST
NEXT J
beep
PRINT "½ªÎ»"
!---------
SUB YbrRGB
!--------- JPG ¿§¶õ´Ö -------------------------
! | Y | | 0.2990 +0.5870 +0.1140 | | R |
! |B-Y| = |-0.1687 -0.3313 +0.5000 | | G |
! |R-Y| | 0.5000 -0.4187 -0.0813 | | B |
!
! | R | | 1
0 +1.40200 | | Y |
! | G | = | 1 -0.34414 -0.71414 | |B-Y|
! | B | |
1 +1.77200
0 | |R-Y|
!----------------------------------------------
FOR V0=0 TO DY-1
FOR U0=0 TO DX-1
LET w1= MOD(D8(U0,V0),256) !R
LET w2=MOD(IP(D8(U0,V0)/256),256) !G
LET w3= IP(D8(U0,V0)/65536) !B
LET D2(U0,V0,0)= 0.2990*w1+0.5870*w2+0.1140*w3 !Y
LET D2(U0,V0,1)=-0.1687*w1-0.3313*w2+0.5000*w3 !Cb
LET D2(U0,V0,2)= 0.5000*w1-0.4187*w2-0.0813*w3 !Cr
NEXT U0
NEXT V0
END SUB
!-----------
SUB DQTINI
RESTORE
!---DQT quantization
FOR j=0 TO 1
FOR V_=0 TO 7
FOR U_=0 TO 7
READ W
LET DQ(U_,V_,j)=CEIL(W/SD) ! inhibit 0
NEXT U_
NEXT V_
NEXT j
!---zigzag-U()V()
FOR V_=0 TO 7
FOR U_=0 TO 7
READ i
LET U(i)=U_
LET V(i)=V_
NEXT U_
NEXT V_
!---HT selection
MAT READ HDC !Y Cb Cr
MAT READ HAC !Y Cb Cr
!---QT selection
MAT READ QS !Y Cb Cr
!---MCU size
MAT MH=CON !Y Cb Cr =1
MAT MV=CON !Y Cb Cr =1
IF 0< CMO THEN
LET MH(0)=2 !Y
LET MV(0)=2 !Y
END IF
END SUB
!---quantization table
!µ±ÅÙ( SMPTE 370M ).Y
!*DQTY
DATA 32, 16, 17, 18, 18, 19, 42, 44
DATA 16, 17, 18, 18, 19, 38, 43, 45
DATA 17, 18, 19, 19, 40, 41, 45, 48
DATA 18, 18, 19, 40, 41, 42, 46, 49
DATA 18, 19, 40, 41, 42, 43, 48,101
DATA 19, 38, 41, 42, 43, 44, 98,104
DATA 42, 43, 45, 46, 48, 98,109,116
DATA 44, 45, 48, 49,101,104,116,123
!---quantization table
!¿§º¹( SMPTE 370M ).Cb Cr
!*DQTC
DATA 32, 16, 17, 25, 26, 26, 42, 44
DATA 16, 17, 25, 25, 26, 38, 43, 91
DATA 17, 25, 26, 27, 40, 41, 91, 96
DATA 25, 25, 27, 40, 41, 84, 93,197
DATA 26, 26, 40, 41, 84, 86,191,203
DATA 26, 38, 41, 84, 86,177,197,209
DATA 42, 43, 91, 93,191,197,219,232
DATA 44, 91, 96,197,203,209,232,246
!---Zigzag table
DATA 0, 1, 5, 6,14,15,27,28
DATA 2, 4, 7,13,16,26,29,42
DATA 3, 8,12,17,25,30,41,43
DATA 9,11,18,24,31,40,44,53
DATA 10,19,23,32,39,45,52,54
DATA 20,22,33,38,46,51,55,60
DATA 21,34,37,47,50,56,59,61
DATA 35,36,48,49,57,58,62,63
!---HT selection
DATA 0,2,2 !DC. Y Cb Cr
DATA 1,3,3 !AC. Y Cb Cr
!---QT selection
DATA 0,1,1 ! Y Cb Cr
!==========================================
! analizing frequency SV(nnnn,ssss) for DHT
SUB ZFRE0
MAT SV=ZER
LET B2(0)=0 ! Y.DC( start prediction)
LET B2(1)=0 ! Cb.DC
LET B2(2)=0 ! Cr.DC
!---
FOR V09=0 TO DV_-1 STEP 8*MV(0)
FOR U09=0 TO DU-1 STEP 8*MH(0)
!---MCU
FOR P=0 TO CMO ! ( 0=Y 1=Cb 2=Cr)
FOR V0=V09 TO V09+8*MV(P)-1 STEP 8
FOR U0=U09 TO U09+8*MH(P)-1 STEP 8
CALL F_BLK0
NEXT U0
NEXT V0
NEXT P
!---
NEXT U09
NEXT V09
!---
CALL MAKE_DHT !DH( ,J) DV( ,J) <--S_( ,J)
END SUB
LET t0=TIME
LET p=1987829
PRINT modpow(3,p-1,p)
PRINT "·×»»»þ´Ö=";TIME-t0
LET t0=TIME
LET s=1
FOR k=1 TO p-1
LET s=MOD(s*3,p)
NEXT k
PRINT s
PRINT "·×»»»þ´Ö=";TIME-t0
END
EXTERNAL FUNCTION modpow(a,n,b) !a^n¢áx mod b ¤Îx¤òÊÖ¤¹¡¡¢¨n¤ÏÈóÉéÀ°¿ô
IF n<0 OR n<>INT(n) THEN !ÈóÉéÀ°¿ô°Ê³°¤Ê¤é
PRINT "modpow´Ø¿ô¤Ç¥Ñ¥é¥á¡¼¥¿¤¬ÉÔŬÅö¤Ç¤¹¡£"
STOP
ELSE
LET S=1
DO WHILE n>0 !¤Ù¤¾èn¤ò£²¿ÊŸ³«¤¹¤ë
IF MOD(n,2)=1 THEN LET S=MOD(S*a,b) !¥Ó¥Ã¥È¤¬£±¤Ê¤é·×»»¤¹¤ë
LET a=MOD(a*a,b)
LET n=INT(n/2)
LOOP
LET modpow=S
END IF
END FUNCTION
-----------------------------------------------
[Äɵ] SET COLOR MODE "NATIVE" ¡Ä¤¬¥À¥á¤Ê¾ì¹ç¡£
SET VIEWPORT 0, 1, 0, 1
SET WINDOW 0,bmx, bmy,0
! SET COLOR MODE "NATIVE" ¢«¼è¤êµî¤ë
ASK PIXEL ARRAY (0,0) D8
(
)
!---------
SUB YbrRGB
(
)
¡¡¡¡¡¡ ¢¤³¤ì¤Ë¡¢º¹Âؤ¨¡£
FOR V0=0 TO DY-1
FOR U0=0 TO DX-1
ASK COLOR MIX( D8(U0,V0)) w1,w2,w3 ! R,G,B (0~1)
LET D2(U0,V0,0)= 255*( 0.2990*w1+0.5870*w2+0.1140*w3) !Y
LET D2(U0,V0,1)= 255*(-0.1687*w1-0.3313*w2+0.5000*w3) !Cb
LET D2(U0,V0,2)= 255*( 0.5000*w1-0.4187*w2-0.0813*w3) !Cr
NEXT U0
NEXT V0
!------------------------
EXTERNAL SUB standard_DHT( DH(,),DV(,) )
OPTION ARITHMETIC NATIVE
FOR j=0 TO 3
LET DH(0,j)=0
FOR i=1 TO 16
READ w$
LET DH(i,j)=BVAL(w$,16)
LET DH(0,j)=DH(0,j)+DH(i,j)
NEXT i
FOR i=0 TO DH(0,j)-1
READ w$
LET DV(i,j)=BVAL(w$,16)
NEXT i
NEXT j
! standard DHT
! ISO/IEC 10918-1:1993(E) Huffman table-specification examples
!
!--Y.DC (K.3)
DATA 00,01,05,01,01,01,01,01,01,00,00,00,00,00,00,00
DATA 00,01,02,03,04,05,06,07,08,09,0A,0B
!--Y.AC (K.5)
DATA 00,02,01,03,03,02,04,03,05,05,04,04,00,00,01,7D
DATA 01,02,03,00,04,11,05,12,21,31,41,06,13,51,61,07
DATA 22,71,14,32,81,91,A1,08,23,42,B1,C1,15,52,D1,F0
DATA 24,33,62,72,82,09,0A,16,17,18,19,1A,25,26,27,28
DATA 29,2A,34,35,36,37,38,39,3A,43,44,45,46,47,48,49
DATA 4A,53,54,55,56,57,58,59,5A,63,64,65,66,67,68,69
DATA 6A,73,74,75,76,77,78,79,7A,83,84,85,86,87,88,89
DATA 8A,92,93,94,95,96,97,98,99,9A,A2,A3,A4,A5,A6,A7
DATA A8,A9,AA,B2,B3,B4,B5,B6,B7,B8,B9,BA,C2,C3,C4,C5
DATA C6,C7,C8,C9,CA,D2,D3,D4,D5,D6,D7,D8,D9,DA,E1,E2
DATA E3,E4,E5,E6,E7,E8,E9,EA,F1,F2,F3,F4,F5,F6,F7,F8
DATA F9,FA
!--C.DC (K.4)
DATA 00,03,01,01,01,01,01,01,01,01,01,00,00,00,00,00
DATA 00,01,02,03,04,05,06,07,08,09,0A,0B
!--C.AC (K.6)
DATA 00,02,01,02,04,04,03,04,07,05,04,04,00,01,02,77
DATA 00,01,02,03,11,04,05,21,31,06,12,41,51,07,61,71
DATA 13,22,32,81,08,14,42,91,A1,B1,C1,09,23,33,52,F0
DATA 15,62,72,D1,0A,16,24,34,E1,25,F1,17,18,19,1A,26
DATA 27,28,29,2A,35,36,37,38,39,3A,43,44,45,46,47,48
DATA 49,4A,53,54,55,56,57,58,59,5A,63,64,65,66,67,68
DATA 69,6A,73,74,75,76,77,78,79,7A,82,83,84,85,86,87
DATA 88,89,8A,92,93,94,95,96,97,98,99,9A,A2,A3,A4,A5
DATA A6,A7,A8,A9,AA,B2,B3,B4,B5,B6,B7,B8,B9,BA,C2,C3
DATA C4,C5,C6,C7,C8,C9,CA,D2,D3,D4,D5,D6,D7,D8,D9,DA
DATA E2,E3,E4,E5,E6,E7,E8,E9,EA,F2,F3,F4,F5,F6,F7,F8
DATA F9,FA
!
END SUB
!-------------------
! make huffman tree
SUB TREE3
MAT Tr=ZER
FOR i=0 TO SE
LET F_(i)=S_(i,P) !¿ôÃͤò²õ¤¹¤Î¤Ç¡¢¥³¥Ô¡¼ F_(i)¤Ç¼Â¹Ô
NEXT i
LET F_(SE+1)=0 !¢« ¶õÀÊÍÑ
!---minimum pair
DO
LET w=1e8
FOR i=0 TO SE+1 !¢«(+1) Éä¹æÌڤκDz¼¤Ë¡¢¶õÀʤò£±¤Äºî¤ë¡£
IF F_(i)< w THEN
LET w=F_(i)
LET Ad1=i ! minimum1 !ÉÑÅٺǾ®¤Îʬ´ô¥¢¥É¥ì¥¹Ad1
END IF
NEXT i
LET w=1e8
FOR i=0 TO SE+1 !¢«(+1) Éä¹æÌڤκDz¼¤Ë¡¢¶õÀʤò£±¤Äºî¤ë¡£
IF F_(i)< w AND i<>Ad1 THEN
LET w=F_(i)
LET Ad2=i ! minimum2 !ÉÑÅٺǾ®¤Îʬ´ô¥¢¥É¥ì¥¹Ad2
END IF
NEXT i
IF w=1e8 THEN EXIT DO !ʬ´ô¤ÎÁȤ¬Ìµ¤¯¤Ê¤ë¤Þ¤Ç
!---
LET F_(Ad1)=F_(Ad1)+F_(Ad2) !¼¡¤ÎÉÑÅٺǾ®¤ÎÁÈõ¤·¤Ï¡¢£²Ê¬´ô¹ç·×¤ò£±¤Ä¤Ë¤·¡¢
LET
F_(Ad2)=1e9 !¾Êý¤ò³°¤·¤Æ¹Ô¤Ê¤¦
!---
FOR Le1=16 TO 1 STEP
-1 !¥¢¥É¥ì¥¹Ad1¤ÎºÇ¾å ÀáÅÀ¥ì¥Ù¥ëLe1 ¤òõ¤¹(ºÇ½é¤ÎLe1=0)
IF Tr(Le1,Ad1,1)>0 OR Tr(Le1,Ad1,3)>0 THEN EXIT FOR
NEXT Le1
FOR Le2=16 TO 1 STEP
-1 !¥¢¥É¥ì¥¹Ad2¤ÎºÇ¾å ÀáÅÀ¥ì¥Ù¥ëLe2 ¤òõ¤¹(ºÇ½é¤ÎLe2=0)
IF Tr(Le2,Ad2,1)>0 OR Tr(Le2,Ad2,3)>0 THEN EXIT FOR
NEXT Le2
LET Le0=MAX( Le1,Le2 )+1 !ξ¼Ô²¿¤ì¤è¤ê¤â£±¤Ä¾å¤ÎÀáÅÀ¥ì¥Ù¥ë(Le0,Ad1)¤Ë¡¢
!---
LET
Tr(Le0,Ad1,0)=Le1 !ʬ´ôÀè(
ÀáÅÀ¥ì¥Ù¥ë,¥¢¥É¥ì¥¹)¤È¤·¤Æ£²ÁȵÆþ
LET Tr(Le0,Ad1,1)=Ad1
LET Tr(Le0,Ad1,2)=Le2
LET Tr(Le0,Ad1,3)=Ad2
LOOP
!---make DH()
LET k=0
CALL bitl(Le0,Ad1) !Á´¥¢¥É¥ì¥¹¤Î nested ÃÊ¿ô¤òµá¤á¤ë¡£
FOR Ad=0 TO SE !nested ÃÊ¿ô¤¬Æ±¤¸ Ad ¤ÎÁí¿ô¤ò¡¢ÃÊ¿ôËè¤Ë½¸·×
LET DH(Tr(0,Ad,1),P)=DH(Tr(0,Ad,1),P)+1
NEXT Ad
LET DH(0,P)=Ad
END SUB
LET cd$(0)="¥¯¥é¥Ö"
LET cd$(1)="¥Ï¡¼¥È"
LET cd$(2)="¥¹¥Ú¡¼¥É"
LET cd$(3)="¥À¥¤¥ä"
! s$()(1:1) ÀèƬ¤Î¿ô»ú= 1,0¡Ê΢,ɽ¡Ë
LET s$( 0)="1¥Ï¡¼¥È¡¡¡¡£¸" !¡¡¡¡£±¡§¥Ï¡¼¥È ¡¡£¸
LET s$( 1)="1¥¹¥Ú¡¼¥É¡¡£³" !¡¡¡¡£²¡§¥¹¥Ú¡¼¥É¡¡£³
LET s$( 2)="1¥Ï¡¼¥È¡¡¡¡£¶" !¡¡¡¡£³¡§¥Ï¡¼¥È¡¡¡¡£¶
LET s$( 3)="1¥À¥¤¥¢¡¡¡¡£¹" !¡¡¡¡£´¡§¥À¥¤¥¢¡¡¡¡£¹
LET s$( 4)="1¥À¥¤¥¢¡¡¡¡£¶" !¡¡¡¡£µ¡§¥À¥¤¥¢¡¡¡¡£¶
LET s$( 5)="0¥À¥¤¥¢¡¡¡¡£Ñ" !¡ö¡¡£¶¡§¥À¥¤¥¢¡¡¡¡Q
LET s$( 6)="1¥À¥¤¥¢¡¡¡¡£Ê" !¡¡¡¡£·¡§¥À¥¤¥¢¡¡¡¡J
LET s$( 7)="0¥¹¥Ú¡¼¥É¡¡£Ñ" !¡ö¡¡£¸¡§¥¹¥Ú¡¼¥É¡¡Q
LET s$( 8)="1¥Ï¡¼¥È¡¡¡¡£Ê" !¡¡¡¡£¹¡§¥Ï¡¼¥È¡¡¡¡J
LET s$( 9)="1¥¹¥Ú¡¼¥É¡¡£¹" !¡¡£±£°¡§¥¹¥Ú¡¼¥É¡¡£¹
LET s$(10)="0¥Ï¡¼¥È¡¡¡¡£µ" !¡ö£±£±¡§¥Ï¡¼¥È¡¡¡¡£µ
LET s$(11)="1¥À¥¤¥¢¡¡¡¡£¸" !¡¡£±£²¡§¥À¥¤¥¢¡¡¡¡£¸
LET s$(12)="1¥¹¥Ú¡¼¥É¡¡£¶" !¡¡£±£³¡§¥¹¥Ú¡¼¥É¡¡£¶
LET s$(13)="0¥Ï¡¼¥È¡¡¡¡£Ñ" !¡ö£±£´¡§¥Ï¡¼¥È¡¡¡¡Q
LET s$(14)="0¥À¥¤¥¢¡¡¡¡£·" !¡ö£±£µ¡§¥À¥¤¥¢¡¡¡¡£·
LET s$(15)="1¥¹¥Ú¡¼¥É¡¡£Ë" !¡¡£±£¶¡§¥¹¥Ú¡¼¥É¡¡K
LET s$(16)="1¥¯¥é¥Ö¡¡¡¡£Ë" !¡¡£±£·¡§¥¯¥é¥Ö¡¡¡¡K
LET s$(17)="1¥Ï¡¼¥È¡¡¡¡£¹" !¡¡£±£¸¡§¥Ï¡¼¥È¡¡¡¡£¹
LET s$(18)="1¥À¥¤¥¢¡¡¡¡£³" !¡¡£±£¹¡§¥À¥¤¥¢¡¡¡¡£³
LET s$(19)="0¥À¥¤¥¢¡¡¡¡£µ" !¡ö£²£°¡§¥À¥¤¥¢¡¡¡¡£µ
LET s$(20)="0¥À¥¤¥¢¡¡£±£°" !¡ö£²£±¡§¥À¥¤¥¢¡¡£±£°
LET s$(21)="0¥¹¥Ú¡¼¥É£±£°" !¡ö£²£²¡§¥¹¥Ú¡¼¥É£±£°
LET s$(22)="1¥¯¥é¥Ö¡¡¡¡£Ê" !¡¡£²£³¡§¥¯¥é¥Ö¡¡¡¡J
LET s$(23)="1¥¯¥é¥Ö¡¡¡¡£¹" !¡¡£²£´¡§¥¯¥é¥Ö¡¡¡¡£¹
LET s$(24)="0¥Ï¡¼¥È¡¡¡¡£²" !¡ö£²£µ¡§¥Ï¡¼¥È¡¡¡¡£²
LET s$(25)="1¥À¥¤¥¢¡¡¡¡£Á" !¡¡£²£¶¡§¥À¥¤¥¢¡¡¡¡A
LET s$(26)="0¥¹¥Ú¡¼¥É¡¡£µ" !¡ö£²£·¡§¥¹¥Ú¡¼¥É¡¡£µ
LET s$(27)="0¥Ï¡¼¥È¡¡£±£°" !¡ö£²£¸¡§¥Ï¡¼¥È¡¡£±£°
LET s$(28)="1¥¹¥Ú¡¼¥É¡¡£¸" !¡¡£²£¹¡§¥¹¥Ú¡¼¥É¡¡£¸
LET s$(29)="1¥¯¥é¥Ö¡¡¡¡£¶" !¡¡£³£°¡§¥¯¥é¥Ö¡¡¡¡£¶
LET s$(30)="0¥Ï¡¼¥È¡¡¡¡£Ë" !¡ö£³£±¡§¥Ï¡¼¥È¡¡¡¡K
LET s$(31)="0¥À¥¤¥¢¡¡¡¡£Ë" !¡ö£³£²¡§¥À¥¤¥¢¡¡¡¡K
LET s$(32)="0¥¹¥Ú¡¼¥É¡¡£´" !¡ö£³£³¡§¥¹¥Ú¡¼¥É¡¡£´
LET s$(33)="0¥¯¥é¥Ö¡¡£±£°" !¡ö£³£´¡§¥¯¥é¥Ö¡¡£±£°
LET s$(34)="0¥¯¥é¥Ö¡¡¡¡£·" !¡ö£³£µ¡§¥¯¥é¥Ö¡¡¡¡£·
LET s$(35)="1¥¯¥é¥Ö¡¡¡¡£Á" !¡¡£³£¶¡§¥¯¥é¥Ö¡¡¡¡A
LET s$(36)="0¥¯¥é¥Ö¡¡¡¡£²" !¡ö£³£·¡§¥¯¥é¥Ö¡¡¡¡£²
LET s$(37)="1¥Ï¡¼¥È¡¡¡¡£Á" !¡¡£³£¸¡§¥Ï¡¼¥È¡¡¡¡A
LET s$(38)="0¥¹¥Ú¡¼¥É¡¡£²" !¡ö£³£¹¡§¥¹¥Ú¡¼¥É¡¡£²
LET s$(39)="0¥Ï¡¼¥È¡¡¡¡£´" !¡ö£´£°¡§¥Ï¡¼¥È¡¡¡¡£´
LET s$(40)="0¥¹¥Ú¡¼¥É¡¡£·" !¡ö£´£±¡§¥¹¥Ú¡¼¥É¡¡£·
LET s$(41)="0¥¯¥é¥Ö¡¡¡¡£´" !¡ö£´£²¡§¥¯¥é¥Ö¡¡¡¡£´
LET s$(42)="1¥¯¥é¥Ö¡¡¡¡£¸" !¡¡£´£³¡§¥¯¥é¥Ö¡¡¡¡£¸
LET s$(43)="1¥¯¥é¥Ö¡¡¡¡£³" !¡¡£´£´¡§¥¯¥é¥Ö¡¡¡¡£³
LET s$(44)="1¥Ï¡¼¥È¡¡¡¡£³" !¡¡£´£µ¡§¥Ï¡¼¥È¡¡¡¡£³
LET s$(45)="0¥À¥¤¥¢¡¡¡¡£²" !¡ö£´£¶¡§¥À¥¤¥¢¡¡¡¡£²
LET s$(46)="0¥À¥¤¥¢¡¡¡¡£´" !¡ö£´£·¡§¥À¥¤¥¢¡¡¡¡£´
LET s$(47)="1¥¹¥Ú¡¼¥É¡¡£Ê" !¡¡£´£¸¡§¥¹¥Ú¡¼¥É¡¡J
LET s$(48)="0¥¯¥é¥Ö¡¡¡¡£Ñ" !¡ö£´£¹¡§¥¯¥é¥Ö¡¡¡¡Q
LET s$(49)="0¥Ï¡¼¥È¡¡¡¡£·" !¡ö£µ£°¡§¥Ï¡¼¥È¡¡¡¡£·
LET s$(50)="1¥¹¥Ú¡¼¥É¡¡£Á" !¡¡£µ£±¡§¥¹¥Ú¡¼¥É¡¡A
LET s$(51)="0¥¯¥é¥Ö¡¡¡¡£µ" !¡ö£µ£²¡§¥¯¥é¥Ö¡¡¡¡£µ
FOR i=0 TO 52
LET A=MOD(i,52)
LET B=MOD(i+1,52)
LET C=MOD(i+2,52)
LET D=MOD(i+3,52)
LET E=MOD(i+4,52)
LET r=MOD(i+5,52)
LET sum= VAL(s$( A )(1:1))*8+VAL(s$( B )(1:1))*4+VAL(s$( E )(1:1))*2+VAL(s$( r )(1:1))
IF MOD(sum,5)=0 THEN
LET N=13
ELSEIF sum< 5 THEN
LET N=sum
ELSEIF 5< sum AND sum< 10 THEN
LET N=sum-1
ELSEIF 10< sum THEN
LET N=sum-2
END IF
PRINT "·×»»¤Î¥«¡¼¥É¡§";cd$( VAL(s$( C )(1:1))*2+VAL(s$( D )(1:1)) );N
PRINT "ºÇ¸å¤Î¥«¡¼¥É¡§";s$( r )(2:7)
PRINT
NEXT i
!¡ü¥Ñ¥¿¡¼¥ó£±¡¡Ãʤȱ¦¼Ð¤á¤¬¡¢¹Ô¤äÎó¤ËÃÖ¤´¹¤ï¤ë
LET N=6 !ÃÊ¿ô
DIM P(0 TO N,0 TO N) !£²¼¡¸µÇÛÎó
MAT P=ZER
LET P(0,0)=1 !º¸µÍ¤á
FOR i=1 TO N
LET P(i,0)=1 !comb(n,n)=comb(n,0)=1
FOR j=1 TO i !comb(n,r)=comb(n-1,r-1)+comb(n-1,r)
LET P(i,j)=P(i-1,j-1)+P(i-1,j) !º¸¾å¡Ü¾å
NEXT j
NEXT i
MAT PRINT USING(REPEAT$("#### ",N+1)): P !¢¨·å¿ô¤¬Â¿¤¤¾ì¹ç¡¢#¤òÁý¤ä¤¹
PRINT
!Îã. ¥Ñ¥¿¡¼¥ó£±¤Îɽõº÷¤Ë¤è¤ë¦²[k=1,N-1]{k}¤Î·×»»
FOR k=1 TO N-1 !±¦¼Ð¤á£±ÈÖÌܤοôÎó¤Ï¡Ö¼«Á³¿ô¡×
PRINT "+";P(k,1);
NEXT k
PRINT "=";P(K,2) !±¦²¼¡ÊK=k+1¡Ë
!Îã. ±ß¼þ¾å¤Ë£Î¸Ä¤ÎÅÀ¤ò¼è¤ê¡¢¸ß¤¤¤Ë·ëÀþ¤·¤Æʬ³ä¤µ¤ì¤ëÎΰè¤Î¿ô
FOR i=1 TO N+1
LET s=0
FOR k=0 TO 4 !º¸¤«¤é£µ¸Ä¤Þ¤Ç
LET s=s+P(i-1,k)
NEXT k
PRINT i;"ÅÀ="; s;"¸Ä"
NEXT i
!Ê̲ò
DIM T(0 TO N)
FOR i=0 TO 4 !¥Ù¥¯¥È¥ë(1,1,1,1,1,0,¡Ä)
LET T(i)=1
NEXT i
MAT T=P*T
MAT PRINT T;
!Îã. ¥Õ¥£¥Ü¥Ê¥Ã¥Á¿ôÎó
FOR i=0 TO N !±¦¼Ð¤á¤ÎÏÂ
LET s=0
FOR j=0 TO i
LET s=s+P(i-j,j)
NEXT j
PRINT s;
NEXT i
PRINT
END
!¡ü¥Ñ¥¿¡¼¥ó£²¡¡º¸¼Ð¤á¤È±¦¼Ð¤á¤¬¡¢¹Ô¤äÎó¤ËÃÖ¤´¹¤ï¤ë
LET N=4 !ÃÊ¿ô
DIM P(0 TO N,0 TO N) !£²¼¡¸µÇÛÎó
MAT P=ZER
FOR j=0 TO N !È¿»þ·×¤Þ¤ï¤ê¤Ë£´£µÅÙ²óž
LET P(0,j)=1 !comb(n,n)=comb(n,0)=1
NEXT j
FOR i=1 TO N
LET P(i,0)=1 !comb(n,n)=comb(n,0)=1
FOR j=1 TO N-i !comb(n,r)=comb(n-1,r-1)+comb(n-1,r)
LET P(i,j)=P(i,j-1)+P(i-1,j) !º¸¡Ü¾å
NEXT j
NEXT i
MAT PRINT USING(REPEAT$("#### ",N+1)): P !¢¨·å¿ô¤¬Â¿¤¤¾ì¹ç¡¢#¤òÁý¤ä¤¹
PRINT
!Îã. £Î¿Í¤ò£é¸Ä¤Î¥°¥ë¡¼¥×¤Ëʬ¤±¤ë¾ì¹ç¤Î¿ô
!
!£³¿Í¤Ç¶¥Áö¤¹¤ë¾ì¹ç
!¡¡£³¿Í¤¬£±°Ì¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£±Ä̤ê¡Ê=comb(3,3)¡Ë
!¡¡£²¿Í¤¬£±°Ì¡¢£±¿Í¤¬£²°Ì¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£³Ä̤ê¡Ê=comb(3,2)*comb(1,1)¡Ë
!¡¡£±¿Í¤¬£±°Ì¡¢£²¿Í¤¬£²°Ì¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡£³Ä̤ê¡Ê=comb(3,1)*comb(2,2)¡Ë
!¡¡£±¿Í¤¬£±°Ì¡¢£±¿Í¤¬£²°Ì¡¢£±¿Í¤¬£³°Ì¡¡¡¡£¶Ä̤ê¡Ê=comb(3,1)*comb(2,1)*comb(1,1)¡Ë
!¡¡¤·¤¿¤¬¤Ã¤Æ¡¢£±£³Ä̤ꡣ
LET c=0
FOR i=0 TO N
LET r=0 !º¸¼Ð¤á¤ÎÏÂ
FOR j=0 TO N-i
LET r=r+(-1)^j*P(i,j) !³ÆÃʤκ¸¤«¤é¶ö¿ôÈÖÌܤòÉé¤Ë¤¹¤ë
NEXT j
LET c=c+r*i^N !½Å¤ß
NEXT i
PRINT c
!Ê̲ò
DIM B(0 TO N,0 TO N) !³ÆÃʤκ¸¤«¤é¶ö¿ôÈÖÌܤòÉé¤Ë¤¹¤ë´ðËܹÔÎó
MAT B=ZER
FOR i=0 TO N
LET B(i,i)=(-1)^i
NEXT i
MAT B=P*B
MAT PRINT B;
DIM T(0 TO N)
MAT T=CON !º¸¼Ð¤á¤Î¿ôÎó¤ò¹ç·×¤¹¤ë
MAT T=B*T
DIM W(1,0 TO N) !½Å¤ß 0^N,1~N,2^N,3^N,¡Ä
FOR i=0 TO N
LET W(1,i)=i^N
NEXT i
MAT PRINT W;
MAT T=W*T
MAT PRINT T; !=W*P*F*CON
!ÊäÂ. £Î¿Í¤ò£é¸Ä¤Î¥°¥ë¡¼¥×¤Ëʬ¤±¤ë¾ì¹ç¤Î¿ô
LET N=4 !¿Í¿ô
!»Ø¿ô·¿Êì´Ø¿ô¤òÍѤ¤¤Æ¤Î²òË¡
!¡¡¿ôÎó{a0,a1,a2,¡Ä,aN,¡Ä}¤ËÂФ·¤Æ¡¢¤³¤Î¿ôÎó¤Î»Ø¿ô·¿Êì´Ø¿ôG(x)¤Ï
!¡¡¡¡G(x)=a0*x^0/0!+a1*x^1/1!+a2*x^2/2!+ ¡Ä +aN*x^N/N!+ ¡Ä
!
!£Î¿Í¤¬½çÈ֤ΰ㤦£é¸Ä¤Î¥°¥ë¡¼¥×¤Ëʬ¤«¤ì¤Æ¥´¡¼¥ë¤·¤¿¤â¤Î¤È¤·¡¢³Æ¥°¥ë¡¼¥×¤Ë¤Ä¤¤¤Æ¹Í¤¨¤ë¡£
!¾ì¹ç¤Î¿ô¡Ê½çÎó¤Î¿ô¡Ë¤ò»Ø¿ô·¿·×¿ô»Ò¤È¤·¤Æɽ¸½¤¹¤ë¤È
!¥°¥ë¡¼¥×Æâ¤Ï£Î¿Í°Ê²¼¤Ê¤é²¿¿Í¤Ç¤âµö¤µ¤ì¡¢¤½¤ÎÆâ¤Ç¤ÎʤÓÊý¤ÏÌäÂê¤È¤·¤Ê¤¤¤Î¤Ç
!¡¡x^0/0!+x^1/1!+x^2/2!+ ¡Ä +x^N/N!+ ¡Ä = EXP(x)
!¤·¤«¤·¡¢¥°¥ë¡¼¥×Æâ¤Ë¤Ï¾¯¤Ê¤¯¤È¤â£±¿Í¤Ï¤¤¤ë¤Î¤Ç
!¡¡x^1/1!+x^2/2!+ ¡Ä +x^N/N!+ ¡Ä = EXP(x)-1
!£é¸Ä¤Î¥°¥ë¡¼¥×¤Ç¤Ï»Ø¿ô·¿·×¿ô»Ò¤Ï
!¡¡(EXP(x)-1)^i
! =¦²[j=0,i]{comb(i,j)*EXP(x)^(i-j)*(-1)^j} //Æó¹àÄêÍý
! =¦²[j=0,i]{comb(i,j)*(-1)^j*EXP((i-j)*x)} //EXP´Ø¿ô¤Î»Ø¿ôÉôʬ¤ò¤Þ¤È¤á¤ë
! =¦²[j=0,i]{comb(i,j)*(-1)^j*¦²[N=0,¡ç]{(i-j)^N*x^N/N!}} //EXP´Ø¿ô¤òµé¿ôŸ³«¤¹¤ë
! =¦²[N=0,¡ç]{x^N/N!*¦²[j=0,i]{comb(i,j)*(-1)^j*(i-j)^N}}
!µá¤á¤ëÃͤϡ¢x^N/N!¤Î·¸¿ô¤Ê¤Î¤Ç
!¡¡¦²[j=0,i]{comb(i,j)*(-1)^j*(i-j)^N}}
!j=i¤Î¤È¤¡¢comb(i,j)*(-1)^j*(i-j)^N = 0 ¤è¤ê
!¡¡¦²[j=0,i-1]{comb(i,j)*(-1)^j*(i-j)^N}}
!¥°¥ë¡¼¥×¤Ï¡¢£±¡Á£Î¤Þ¤Ç¤¢¤ë¤Î¤Ç
!¡¡¦²[i=1,N]{¦²[j=0,i-1]{comb(i,j)*(-1)^j*(i-j)^N}}}
LET f=0 !°ìÈÌ¹à ¦²[i=1,N]{¦²[j=0,i-1]{(-1)^j*comb(i,j*(i-j)^j}}
FOR i=1 TO N
FOR j=0 TO i-1
LET f=f+(-1)^j*comb(i,j)*(i-j)^N
NEXT j
NEXT i
PRINT f !·ë²Ì¤òɽ¼¨¤¹¤ë
!¾å¼°¤òŸ³«¤·¤Æ¡¢i^N¤Ç¤Þ¤È¤á¤ë¤È
!¡¡¦²[i=1,N]{¦²[j=0,N-i]{(-1)^j*comb(i+j,j)*i^N}}
LET f=0 !°ìÈÌ¹à ¦²[i=1,N]{¦²[j=0,N-i]{(-1)^j*comb(i+j,j)*i^N}}
FOR i=1 TO N
FOR j=0 TO N-i
LET f=f+(-1)^j*comb(i+j,j)*i^N
NEXT j
NEXT i
PRINT f !·ë²Ì¤òɽ¼¨¤¹¤ë
!¤³¤Î¼°¤ò¤è¤¯¸«¤ë¤È¡¢¥Ñ¥¹¥«¥ë¤Î»°³Ñ·Á¤Ë¤è¤ë²òË¡¤Ø
!¡¡¡¡¡§
!¡¡¡¡¡§
END
!Ê̲ò
!A={a1,a2,a3,Ž¥Ž¥Ž¥,an}¡¢B={b1,b2,b3,¡Ä,bm}¤Î¤È¤¡¢A¤«¤éB¤Ø¤ÎÁ´¼Í¤Î¿ô
!¡¡¦²[k=0,m]{(-1)^k*comb(m,k)*(m-k)^n}
!
!¾å¼°¤Ï¡¢Êñ½ü¸¶Íý¤è¤êµá¤á¤é¤ì¤ë¡£
!µá¤á¤ëÃͤϡ¢m=1¡Án¤è¤ê¡£
!¡¡¦²[m=1,n]{¦²[k=0,m]{(-1)^k*comb(m,k)*(m-k)^n}}
LET n=5
LET f=0
FOR m=1 TO n
FOR k=0 TO m
LET f=f+(-1)^k*comb(m,k)*(m-k)^n
NEXT k
NEXT m
PRINT f
END
!½çÎó perm(n,r) Ä̤ê¤Î¥Ñ¥¿¡¼¥ó¤Ë¡¢0 ¡Á perm(n,r)-1 ¤ÎÈÖ¹æ¤ò¤Ä¤±¤ëÊýË¡
LET N=4 !£±¡Á£Î¤Þ¤Ç¤Î¿ô»ú¤ò»È¤¦
LET R=4
DATA 1,2,3,4 !½çÎó PERM(N,N)=FACT(N) ¤Î¥Æ¥¹¥È¡¦¥Ç¡¼¥¿
DATA 1,2,4,3
DATA 1,3,2,4
DATA 1,3,4,2
DATA 1,4,2,3
DATA 1,4,3,2
DATA 2,1,3,4
DATA 2,1,4,3
DATA 2,3,1,4
DATA 2,3,4,1
DATA 2,4,1,3
DATA 2,4,3,1
DATA 3,1,2,4
DATA 3,1,4,2
DATA 3,2,1,4
DATA 3,2,4,1
DATA 3,4,1,2
DATA 3,4,2,1
DATA 4,1,2,3
DATA 4,1,3,2
DATA 4,2,1,3
DATA 4,2,3,1
DATA 4,3,1,2
DATA 4,3,2,1
DIM A(R),B(R)
FOR d=1 TO PERM(N,R) !¥Ç¡¼¥¿¤òÆɤ߹þ¤à
MAT READ A
LET h=Perm2Num(A,N,R)
PRINT h !·ë²Ì¤òɽ¼¨¤¹¤ë
CALL Num2Perm(h, B,N,R) !Éü¸µ¤¹¤ë
MAT PRINT B;
MAT PRINT A; !¸¡»»
NEXT d
END
!ºÇ¾®´°Á´¥Ï¥Ã¥·¥å´Ø¿ô
EXTERNAL FUNCTION Perm2Num(A(),N,R) !½çÎó¥Ñ¥¿¡¼¥ó¤ËÈÖ¹æ¤òÉÕ¤±¤ë¡¡¢¨¼½ñ¼°½ç½ø
LET v=0
FOR j=1 TO R
LET t=A(j)
LET v=v+perm(N-j,R-j)*(t-1)
FOR k=j+1 TO R
IF A(k)>t THEN LET A(k)=A(k)-1
NEXT k
NEXT j
LET Perm2Num=v
END FUNCTION
EXTERNAL SUB Num2Perm(h, A(),N,R) !Èֹ椫¤é½çÎó¥Ñ¥¿¡¼¥ó¤òÀ¸À®¤¹¤ë¡¡¢¨¼½ñ¼°½ç½ø
LET v=h
FOR j=1 TO R
LET fac=perm(N-j,R-j)
LET t=INT(v/fac)
LET A(j)=t+1 !£±¡Á£Î
LET v=v-fac*t
NEXT j
FOR j=R TO 1 STEP -1
FOR k=j+1 TO R
IF A(j)<=A(k) THEN LET A(k)=A(k)+1
NEXT k
NEXT j
END SUB
¡üÁȹ礻·¿
!Áȹ礻 comb(n,r) Ä̤ê¤Î¥Ñ¥¿¡¼¥ó¤Ë¡¢0 ¡Á comb(n,r)-1 ¤ÎÈÖ¹æ¤ò¤Ä¤±¤ëÊýË¡
LET N=6 !£±¡Á£Î¤Þ¤Ç¤Î¿ô»ú¤ò»È¤¦
LET R=3
DATA 1,2,3 !Áȹ礻 comb(6,3)=20 ¤Î¥Æ¥¹¥È¡¦¥Ç¡¼¥¿
DATA 1,2,4 !¢¨¿ô»ú¤Ï¾®¤µ¤¤½ç
DATA 1,2,5
DATA 1,2,6
DATA 1,3,4
DATA 1,3,5
DATA 1,3,6
DATA 1,4,5
DATA 1,4,6
DATA 1,5,6
DATA 2,3,4
DATA 2,3,5
DATA 2,3,6
DATA 2,4,5
DATA 2,4,6
DATA 2,5,6
DATA 3,4,5
DATA 3,4,6
DATA 3,5,6
DATA 4,5,6
DIM A(R),B(R)
FOR d=1 TO comb(N,R) !¥Ç¡¼¥¿¤òÆɤ߹þ¤à
MAT READ A
LET h=Comb2Num(A,N,R)
PRINT h !·ë²Ì¤òɽ¼¨¤¹¤ë
CALL Num2Comb(h, B,N,R) !Éü¸µ¤¹¤ë
MAT PRINT B;
MAT PRINT A; !¸¡»»
NEXT d
END
!ºÇ¾®´°Á´¥Ï¥Ã¥·¥å´Ø¿ô
EXTERNAL FUNCTION Comb2Num(A(),N,R) !Áȹ礻¥Ñ¥¿¡¼¥ó¤ËÈÖ¹æ¤òÉÕ¤±¤ë¡¡¢¨¼½ñ¼°½ç½ø
LET v=0
FOR i=R TO 1 STEP -1 !Áȹ礻¤ò¥Ó¥Ã¥È°ÌÃ֤Ȥ¹¤ë
LET t=N-A(i)
LET v=v+COMB(t,R-i+1)
NEXT i
LET Comb2Num=(comb(N,R)-1)-v
END FUNCTION
EXTERNAL SUB Num2Comb(h, A(),N,R) !Èֹ椫¤éÁȹ礻¥Ñ¥¿¡¼¥ó¤òÀ¸À®¤¹¤ë¡¡¢¨¼½ñ¼°½ç½ø
LET v=comb(N,R)-h
LET m=R
FOR i=N-1 TO 0 STEP -1 !Áȹ礻¤ò¥Ó¥Ã¥È°ÌÃ֤Ȥ¹¤ë
LET t=COMB(i,m)
IF v>t THEN
LET A(R-m+1)=N-i !¥Ó¥Ã¥È°ÌÃÖ(N-i-1)¤ò£±¤È¤¹¤ë
LET m=m-1
LET v=v-t
END IF
NEXT i
END SUB
EXTERNAL FUNCTION Comb2Num2(A(),N,R) !Áȹ礻¥Ñ¥¿¡¼¥ó¤ËÈÖ¹æ¤òÉÕ¤±¤ë¡¡¢¨¼½ñ¼°½ç½ø¤Ç¤Ï¤Ê¤¤
LET v=0
FOR i=R TO 1 STEP -1
LET t=A(i)-1 !Áȹ礻¤ò¥Ó¥Ã¥È°ÌÃ֤Ȥ¹¤ë
LET v=v+COMB(t,i)
NEXT i
LET Comb2Num2=v
END FUNCTION
EXTERNAL SUB Num2Comb2(h, A(),N,R) !Èֹ椫¤éÁȹ礻¥Ñ¥¿¡¼¥ó¤òÀ¸À®¤¹¤ë¡¡¢¨¼½ñ¼°½ç½ø¤Ç¤Ï¤Ê¤¤
LET v=h
LET m=R
FOR i=N-1 TO 0 STEP -1 !Áȹ礻¤ò¥Ó¥Ã¥È°ÌÃ֤Ȥ¹¤ë
LET t=COMB(i,m)
IF t<=v THEN
LET A(m)=i+1 !¥Ó¥Ã¥È°ÌÃÖi¤ò£±¤È¤¹¤ë
LET m=m-1
LET v=v-t
END IF
NEXT i
END SUB
100 DEF base(j)=2^MOD(j+2,3)+2^MOD(j+2,3)*10*(1-INT(j/3.01)) ! 11,22,44,1,2,4
110 FUNCTION change(p$)
120 IF UCASE$(p$)="R" THEN
130 LET c=0
140 ELSEIF UCASE$(p$)="B" THEN
150 LET c=1
160 ELSE
170 PRINT "ERROR-2 !!"
180 END IF
190 LET change=c
200 END FUNCTION
210 INPUT PROMPT "ÀÖ¤ò""R"",¹õ¤ò""B""¤È¤·¤¿Ê¸»úÎó = ":rb$ ! Îã) brbbrr
220 IF LEN(rb$)<>6 THEN PRINT "ERROR-1 !!"
230 LET d=10
240 FOR j=1 TO 6
250 LET d=d+change(rb$(j:j))*base(j)
260 NEXT j
270 PRINT "²òÅú =";d
280 END
DIM base(6),dwn(6),check(6)
MAT READ base,dwn
FUNCTION number(q)
LET dd=10
FOR jj=1 TO 6
IF jj<>q THEN
LET dd=dd+check(jj)*base(jj)
ELSE
LET dd=dd+((check(jj)-1)^2)*base(jj)
END IF
NEXT jj
LET number=dd
END FUNCTION
FOR n=10 TO 94
MAT check=ZER
LET d=10
LET nn=n-d
FOR j=1 TO 6 ! base¤ÎÂ礤¤¿ô¤«¤é°ú¤¤¤Æ¤¤¤¯
IF nn-base(dwn(j))>=0 THEN
LET check(dwn(j))=1
LET d=d+base(dwn(j))
LET nn=nn-base(dwn(j))
END IF
NEXT j
IF n=d THEN
LET check(1)=(check(1)-1)^2 ! 0,1¤ÎÆþ¤ì´¹¤¨
FOR j=1 TO 6
PRINT number(j);
NEXT j
PRINT
FOR j=1 TO 6
IF check(j)=0 THEN PRINT " ÀÖ "; ELSE PRINT " ¹õ ";
NEXT j
PRINT
ELSE
PRINT n;" ¤³¤Î¿ô¤ÏÀ¸À®¤Ç¤¤Þ¤»¤ó"
END IF
NEXT n
DATA 11,22,44,1,2,4 ! base
DATA 3,2,1,6,5,4 ! base¤Î¹ß½ç
END
DIM W(6) !½Å¤ß
DATA 32,16,8,4,2,1 !Àµ²ò 11,22,44,1,2,4
MAT READ W
!£±ÎóÌÜ 010101¡¡0:ÀÖ¡¢1:¹õ
100 DATA 1,1,0,1,0,1, 48 !µÒ¤¬Åú¤¨¤¿ÀÖ¹õ¤Î¥Ñ¥¿¡¼¥ó¡¢»×¤Ã¤Æ¤¤¤¿¿ô
DATA 0,0,0,1,0,1, 15
DATA 0,1,1,1,0,1, 81
DATA 0,1,0,0,0,1, 36
DATA 0,1,0,1,1,1, 39
DATA 0,1,0,1,0,0, 33
!£²ÎóÌÜ 011110
DATA 1,1,1,1,1,0, 90
DATA 0,0,1,1,1,0, 57
DATA 0,1,0,1,1,0, 35
DATA 0,1,1,0,1,0, 78
DATA 0,1,1,1,0,0, 77
DATA 0,1,1,1,1,1, 83
!£³ÎóÌÜ 100011
DATA 0,0,0,0,1,1, 16
DATA 1,1,0,0,1,1, 49
DATA 1,0,1,0,1,1, 71
DATA 1,0,0,1,1,1, 28
DATA 1,0,0,0,0,1, 25
DATA 1,0,0,0,1,0, 23
!£´ÎóÌÜ 101101
DATA 0,0,1,1,0,1, 59
DATA 1,1,1,1,0,1, 92
DATA 1,0,0,1,0,1, 26
DATA 1,0,1,0,0,1, 69
DATA 1,0,1,1,1,1, 72
DATA 1,0,1,1,0,0, 66
!£µÎóÌÜ 001110
DATA 1,0,1,1,1,0, 68
DATA 0,1,1,1,1,0, 79
DATA 0,0,0,1,1,0, 13
DATA 0,0,1,0,1,0, 56
DATA 0,0,1,1,0,0, 55
DATA 0,0,1,1,1,1, 61
!£¶ÎóÌÜ 110011
DATA 0,1,0,0,1,1, 38
DATA 1,0,0,0,1,1, 27
DATA 1,1,1,0,1,1, 93
DATA 1,1,0,1,1,1, 50
DATA 1,1,0,0,0,1, 47
DATA 1,1,0,0,1,0, 45
!£·ÎóÌÜ 111000
DATA 0,1,1,0,0,0, 76
DATA 1,0,1,0,0,0, 65
DATA 1,1,0,0,0,0, 43
DATA 1,1,1,1,0,0, 88
DATA 1,1,1,0,1,0, 89
DATA 1,1,1,0,0,1, 91
SET WINDOW -5,100,-5,100
DIM P(6)
FOR t=0 TO fact(6)-1 !½Å¤ß¤Î½çÎó¤òÀ¸À®¤¹¤ë
CALL Num2Perm(t,P,6)
RESTORE 100
CLEAR
DRAW grid(10,10)
FOR d=1 TO 6*7 !¥µ¥ó¥×¥ë¡¦¥Ç¡¼¥¿¤è¤ê
DIM B(6) !µÒ¤¬Åú¤¨¤¿ÀÖ¹õ¤Î¥Ñ¥¿¡¼¥ó
MAT READ B
READ y !»×¤Ã¤Æ¤¤¤¿¿ô
LET x=0 !Àþ·Á¼ÌÁü
FOR i=1 TO 6
LET x=x+W(P(i))*B(i)
NEXT i
PLOT POINTS: x,y !¤è¤êľÀþ¤Ë¤Ê¤ë¤Î¤¬¸õÊ䡪
NEXT d
FOR i=1 TO 6 !½Å¤ß¤Î½çÎó¤òɽ¼¨¤¹¤ë
PRINT W(P(i));
NEXT i
PRINT
WAIT DELAY 0.3 !¢¨Ä´À°¤¬É¬Í×
NEXT t
END
!n!¤Î½çÎó¥Ñ¥¿¡¼¥ó ¢Î 0¡Á(n!-1)¤ÎÈÖ¹æ
EXTERNAL FUNCTION Perm2Num(A(),N) !½çÎó¥Ñ¥¿¡¼¥ó¤ËÈÖ¹æ¤òÉÕ¤±¤ë¡¡¢¨¼½ñ¼°½ç½ø
LET v=0
FOR j=1 TO N-1 !¢¨N¤Ç¤Ï£°
LET t=A(j)
LET v=v+fact(N-j)*(t-1)
FOR k=j+1 TO N
IF A(k)>t THEN LET A(k)=A(k)-1
NEXT k
NEXT j
LET Perm2Num=v
END FUNCTION
EXTERNAL SUB Num2Perm(h, A(),N) !Èֹ椫¤é½çÎó¥Ñ¥¿¡¼¥ó¤òÀ¸À®¤¹¤ë¡¡¢¨¼½ñ¼°½ç½ø
LET v=h
FOR j=1 TO N
LET fac=fact(N-j)
LET t=INT(v/fac)
LET A(j)=t+1 !£±¡Á£Î
LET v=v-fac*t
NEXT j
FOR j=N TO 1 STEP -1
FOR k=j+1 TO N
IF A(j)<=A(k) THEN LET A(k)=A(k)+1
NEXT k
NEXT j
END SUB
!BMP¥Õ¥¡¥¤¥ë¡Ê°µ½Ì¤Ê¤·¡Ë²èÁü¤ÎÉôʬÎΰè¡ÊÀÚ¤ê½Ð¤·¡Ë¤òɽ¼¨¤¹¤ë
!»²¹Í http://www.kk.iij4u.or.jp/~kondo/bmp/
OPTION CHARACTER byte
LET CX1=0 !ÀÚ¤ê½Ð¤¹²èÁüÎΰè¤Îº¸¾åºÂɸ¡Ê¥Ô¥¯¥»¥ëñ°Ì¡Ë
LET CY1=0
LET CX2=640 !±¦²¼ºÂɸ
LET CY2=480
SET COLOR mode "NATIVE"
SET bitmap SIZE CX2-CX1,CY2-CY1 !¥¹¥¯¥ê¡¼¥óºÂɸ¤Ø
SET WINDOW 0,CX2-CX1-1,CY2-CY1-1,0 !²èÌ̤ò²èÁü¥µ¥¤¥º¤Ø
SET POINT STYLE 1 !¥É¥Ã¥È·Á¼°
LET BFile$=REPEAT$(CHR$(0),14) !Dim BFile As BITMAPFILEHEADER
LET BInfo$=REPEAT$(CHR$(0),40) !Dim BInfo As BITMAPINFOHEADER
LET BPalt$=REPEAT$(CHR$(0),4) !Dim BPalt As RGBQUAD
file getname f$,"BMP¥Õ¥¡¥¤¥ë|*.BMP" !¥Õ¥¡¥¤¥ë̾¤òÆÀ¤ë
IF f$="" THEN STOP
OPEN #1: NAME f$, ACCESS INPUT
LET cp=0 !Æɤ߹þ¤ß¸½ºß°ÌÃÖ
!---------- ¥Õ¥¡¥¤¥ë¥Ø¥Ã¥ÀÉô
LET p=0 !Æɤ߹þ¤ß°ÌÃÖ
CALL fseek(p) !Get #1,0,BFile¡¡¢¨VisualBasic
CALL fread(BFile$,p)
IF BFile$(1:2)="MB" THEN !BFile.bfType
PRINT "£Â£Í£Ð¥Õ¥¡¥¤¥ë¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£"
STOP
END IF
LET bfOffBits=CVI(BFile$,10,4) !BFile.bfOffBits
PRINT "bfOffBits=";bfOffBits
PRINT
!---------- ¾ðÊó¥Ø¥Ã¥ÀÉô¡ÊWindows Bitmap¡Ë
CALL fread(BInfo$,p) !Get #1, ,BInfo
LET biWidth=CVI(BInfo$,4,4) !BInfo.biWidth
PRINT "biWidth=";biWidth
LET biHeight=CVI(BInfo$,8,4) !BInfo.biHeight
PRINT "biHeight=";biHeight
LET biBitCount=CVI(BInfo$,14,2) !BInfo.biBitCount
PRINT "biBitCount=";biBitCount
LET biCompression=CVI(BInfo$,16,4) !BInfo.biCompression
PRINT "biCompression=";biCompression
PRINT
!---------- ¾ðÊó¥Ø¥Ã¥ÀÉô¡Ê¥Ñ¥ì¥Ã¥ÈÉô¡Ë
DIM PAL(0 TO 255,4)
IF biBitCount<=8 THEN
FOR k=0 TO 2^biBitCount-1
CALL fread(BPalt$,p) !Get #1, ,BPalt
!!PRINT USING "### ÈÖ¡¡": k;
!!PRINT CVI2(BPalt$,0,1), !BPalt.rgbBlue¡¡¢¨Éä¹æ¤Ê¤·
!!PRINT CVI2(BPalt$,1,1), !BPalt.rgbGreen
!!PRINT CVI2(BPalt$,2,1), !BPalt.rgbRed
!!PRINT CVI2(BPalt$,3,1) !BPalt.rgbReserved
LET PAL(k,3)=CVI2(BPalt$,0,1)/255 !BPalt.rgbBlue¡¡¢¨Éä¹æ¤Ê¤·
LET PAL(k,2)=CVI2(BPalt$,1,1)/255 !BPalt.rgbGreen
LET PAL(k,1)=CVI2(BPalt$,2,1)/255 !BPalt.rgbRed
LET PAL(k,4)=CVI2(BPalt$,3,1)/255 !BPalt.rgbReserved
NEXT k
END IF
PRINT
IF biCompression<>0 THEN
PRINT "°µ½Ì·Á¼°¤Ï̤¥µ¥Ý¡¼¥È¤Ç¤¹¡£"
STOP
END IF
!---------- ²èÁü¥Ç¡¼¥¿Éô
!SET DRAW mode hidden !¤Á¤é¤Ä¤Ëɻߤγ«»Ï
LET p=bfOffBits !¥Õ¥¡¥¤¥ëÆâ¤Î²èÁü¥Ç¡¼¥¿¤ÎÀèƬ°ÌÃÖ
CALL fseek(p)
LET L1=biWidth*biBitCount/8
LET L1b=(INT((L1-1)/4)+1)*4 !£´¥Ð¥¤¥È¶³¦
FOR y=1 TO biHeight
LET BData$=REPEAT$(CHR$(0),L1b) !£±¹Ôʬ¤Î²èÁü¥Ç¡¼¥¿
CALL fread(BData$,p) !Get #1, ,BData
IF y>=biHeight-CY2 AND y<=biHeight-CY1 THEN !ÀÚ¤ê½Ð¤·ÎΰèÆâ¤Ê¤é¡¡¢¨²¼¤«¤é³ÊǼ¤µ¤ì¤Æ¤¤¤ë
SELECT CASE biBitCount
CASE 1 !2¿§
FOR x=MAX(INT((CX1-1)/8),0) TO L1b-1 !£±¹Ôʬ¤Î²èÁü¥Ç¡¼¥¿¡ÊÀÚ¤ê½Ð¤·ÎΰèÆ⺸ü¤«¤é¡Ë
!!PRINT "(";8/biBitCount*x+1;",";y;")",
LET b=CVI2(BData$,x,1)
!!!PRINT right$("0000000"&BSTR$(b,2),8)
LET t$=right$("0000000"&BSTR$(b,2),8)
LET bb=1
DO UNTIL bb>8
LET xx=x*8+bb-1
IF xx>CX2 THEN EXIT FOR !ÀÚ¤ê½Ð¤·ÎΰèÆⱦü¤Ê¤é
IF xx>=CX1 THEN
IF xx<=biWidth THEN
LET t=VAL(t$(bb:bb))
SET POINT COLOR colorindex(PAL(t,1),PAL(t,2),PAL(t,3))
PLOT POINTS: xx - CX1, biHeight-y - CY1 !¢¨²¼¤«¤é³ÊǼ¤µ¤ì¤Æ¤¤¤ë
END IF
END IF
LET bb=bb+1
LOOP
NEXT x
CASE 4 !16¿§
FOR x=MAX(INT((CX1-1)/2),0) TO L1b-1 !£±¹Ôʬ¤Î²èÁü¥Ç¡¼¥¿¡ÊÀÚ¤ê½Ð¤·ÎΰèÆ⺸ü¤«¤é¡Ë
!!PRINT "(";8/biBitCount*x+1;",";y;")",
LET b=CVI2(BData$,x,1)
!!PRINT INT(b/16); !¾å4bit
!!PRINT MOD(b,16) !²¼4bit
LET xx=8/biBitCount*x+1
IF xx>CX2 THEN EXIT FOR !ÀÚ¤ê½Ð¤·ÎΰèÆⱦü¤Ê¤é
IF xx>=CX1 THEN
IF xx<=biWidth THEN
LET t=INT(b/16) !¾å4bit
SET POINT COLOR colorindex(PAL(t,1),PAL(t,2),PAL(t,3))
PLOT POINTS: xx - CX1, biHeight-y - CY1 !¢¨²¼¤«¤é³ÊǼ¤µ¤ì¤Æ¤¤¤ë
END IF
END IF
IF xx+1>CX2 THEN EXIT FOR !ÀÚ¤ê½Ð¤·ÎΰèÆâ¤Ê¤é
IF xx+1>=CX1 THEN
IF xx<=biWidth THEN
LET t=MOD(b,16) !²¼4bit
SET POINT COLOR colorindex(PAL(t,1),PAL(t,2),PAL(t,3))
PLOT POINTS: xx+1 - CX1, biHeight-y - CY1 !¢¨²¼¤«¤é³ÊǼ¤µ¤ì¤Æ¤¤¤ë
END IF
END IF
NEXT x
CASE ELSE !256¿§¡¢24¥Ó¥Ã¥È¿§¡¢32¥Ó¥Ã¥È¿§
FOR x=MAX(CX1,1) TO MIN(CX2,biWidth) !ÀÚ¤ê½Ð¤·ÎΰèÆâ
LET t=(x-1)*biBitCount/8
!!PRINT "(";x;",";y;")",
!!FOR k=0 TO biBitCount/8-1
!! PRINT CVI2(BData$,t+k,1); !BData¡¡¢¨Éä¹æ¤Ê¤·
!!NEXT k
!!PRINT
IF biBitCount=8 THEN !256¿§¤Ê¤é
LET tt=CVI2(BData$,t+0,1)
SET POINT COLOR colorindex(PAL(tt,1),PAL(tt,2),PAL(tt,3))
ELSE
LET bb=CVI2(BData$,t+0,1) !BData¡¡¢¨Éä¹æ¤Ê¤·
LET gg=CVI2(BData$,t+1,1)
LET rr=CVI2(BData$,t+2,1)
SET POINT COLOR colorindex(rr/255,gg/255,bb/255)
END IF
PLOT POINTS: x - CX1, biHeight-y - CY1 !¢¨²¼¤«¤é³ÊǼ¤µ¤ì¤Æ¤¤¤ë
NEXT x
END SELECT
END IF
NEXT y
!SET DRAW mode explicit !¤Á¤é¤Ä¤ËɻߤνªÎ»
CLOSE #1
!¥Õ¥¡¥¤¥ë´ØÏ¢
SUB fseek(p) !Æɤ߹þ¤ß°ÌÃÖ¤òÀßÄꤹ¤ë
IF p<cp THEN !Á°¤Ø
SET #1: POINTER BEGIN
LET cp=0
END IF
FOR i=1 TO p-cp !skip it
CHARACTER INPUT #1: tmp$
NEXT i
LET cp=p !¸½ºß°ÌÃ֤ι¹¿·
END SUB
SUB fread(r$,p) !¥ì¥³¡¼¥É¤òÆɤ߹þ¤à
FOR i=1 TO LEN(r$) !read it
CHARACTER INPUT #1: r$(i:i)
NEXT i
LET p=p+LEN(r$) !¸½ºß°ÌÃ֤ι¹¿·
LET cp=p
END SUB
END
EXTERNAL FUNCTION CVI(s$,p,m) !ʸ»úÎó¤ËËä¤á¹þ¤Þ¤ì¤¿m*8¥Ó¥Ã¥ÈÉä¹æÉÕ¤À°¿ô¤ò¼è¤ê½Ð¤¹
OPTION CHARACTER byte
LET n=0
FOR i=1 TO m
LET n=n+256^(i-1)*ORD(s$(p+i:p+i))
NEXT i
IF n<2^(m*8-1) THEN LET CVI=n ELSE LET CVI=n-2^(m*8)
END FUNCTION
EXTERNAL FUNCTION CVI2(s$,p,m) !ʸ»úÎó¤ËËä¤á¹þ¤Þ¤ì¤¿m*8¥Ó¥Ã¥ÈÉä¹æ¤Ê¤·À°¿ô¤ò¼è¤ê½Ð¤¹
OPTION CHARACTER byte
LET n=0
FOR i=1 TO m
LET n=n+256^(i-1)*ORD(s$(p+i:p+i))
NEXT i
LET CVI2=n
END FUNCTION
!½½¿ÊBASIC ¤Î¥°¥é¥Õµ¡Ç½¤À¤±¤Ç¤Î½èÍý¤Ç¤¹¤¬¡¢5000 x 4500 ¤Ï¡¢¤É¤ó¤Ê¤Ç¤·¤ç¤¦¡£
OPTION ARITHMETIC NATIVE
SET COLOR mode "NATIVE"
OPTION BASE 0
DIM D(1000,1000)
ASK directory currentD$
!
SET directory "C:\WINDOWS\ŽÃŽÞŽ½Ž¸ŽÄŽ¯ŽÌŽß" !ºÇ½é¤Ë³«¤¯directory¡Êºï½ü¡§¥Þ¥¤¥É¥¥å¥á¥ó¥È¡Ë
FILE GETNAME file$, "BMP"
IF file$="" THEN
PRINT "ÆþÎÏ¥Õ¥¡¥¤¥ë̵̾¤·¤Ç¡¢Ãæ»ß¡£"
STOP
END IF
PRINT "ÆþÎÏ¥Õ¥¡¥¤¥ë¡§"& file$
!
!---¸¶²è¤ò¥í¡¼¥É¡¢¥°¥é¥ÕºÂɸ¤ò¡¢º¸¾å¤«¤é±¦²¼Êý¸þ¤Ø²èÁÇñ°Ì¤ËÀßÄê
gload file$
ASK PIXEL SIZE xw,yw
SET WINDOW 0,xw,yw,0
PRINT xw+1;"*";yw+1;"²èÁǤ趲è"
!
!---¸¶²è¤«¤é¡¢ÀڽФ·¤¿¤¤²èÁǤÎÈϰϤò½ñ¤¯
LET X0=10 !º¸
LET Y0=20 !¾å
LET X1=200 !±¦
LET Y1=200 !²¼
!
!---ÀÚ¤ê½Ð¤·
MAT D=ZER(X1-X0,Y1-Y0)
ASK PIXEL ARRAY (X0,Y0) D
!
!---ÀÚ¤ê½Ð¤·²èÁü¤Îɽ¼¨
SET bitmap SIZE X1-X0+1,Y1-Y0+1
MAT PLOT CELLS,IN 0,1;1,0 :D
PRINT "(";X0;",";Y0;")¤«¤é¡¢";"(";X1;",";Y1;")¤Þ¤Ç¤ÎÀÚ¤ê½Ð¤·²èÁü"
!
!---ÀÚ¤ê½Ð¤·²èÁü¤ÎÊݸ¤È¡¢ºÆɽ¼¨
SET directory currentD$
gsave "sample.bmp"
gload "sample.bmp"
SET bitmap SIZE 501,501
!¡ü7^2009¤Î²¼£´·å
OPTION ARITHMETIC RATIONAL !¿·åÀ°¿ô
!7*7=49=50-1¤è¤ê¡¢7^2000=(50-1)^1000
!¤³¤ì¤òÆó¹àÄêÍý¤ÇŸ³«¤¹¤ë¤È¡¢
!¡¡¹à comb(1000,r)*50^r*(-1)^(1000-r)¡¢r=0,1,2,3,¡Ä
!¤ÎϤȤʤ롣
!r=4°Ê¾å¡¢50^r¤¬10000¤Ç³ä¤êÀÚ¤ì¤ë¤«¤é¡¢²¼£´·å¤Ï¤¹¤Ù¤Æ£°¤È¤Ê¤ë¡£
LET s=0
!r=3,2,1,0¤Î¤È¤
FOR r=3 TO 0 STEP -1
LET s=s + comb(1000,r)*50^r*(-1)^(1000-r)
NEXT r
PRINT MOD(s*7^9,10^5) !»Ä¤ê7^9¤ò²ÃÌ£¤·¤Æ
END
PRINT "--- ¥Ñ¥ê¥Æ¥£ ¹ÔÎó h"
MAT READ h
DATA 0,0,0,1 ! 1 ! 0 ¤Ï ¥¨¥é¡¼Ìµ¤·¤ÎͽÌóÃÍ¡£
DATA 0,0,1,0 ! 2
DATA 0,0,1,1 ! 3
DATA 0,1,0,0 ! 4
DATA 0,1,0,1 ! 5
DATA 0,1,1,0 ! 6
DATA 0,1,1,1 ! 7
DATA 1,0,0,0 ! 8
DATA 1,0,0,1 ! 9
DATA 1,0,1,0 ! 10
DATA 1,0,1,1 ! 11
DATA 1,1,0,0 ! 12
DATA 1,1,0,1 ! 13
DATA 1,1,1,0 ! 14 !¥ª¡¼¥ë£±¤Î¡¢15 ¤â»ÈÍѤǤ¤Ê¤¤¡£(¢¨Ãí)
LET M(1,11)=MOD( M(1,4)+M(1,5)+M(1,6)+M(1,7)+M(1,8)+M(1,9)+M(1,10) ,2)
LET M(1,12)=MOD( M(1,1)+M(1,2)+M(1,4)+M(1,7)+M(1,9)+M(1,10) ,2)
LET M(1,13)=MOD( M(1,1)+M(1,3)+M(1,4)+M(1,6)+M(1,8)+M(1,10) ,2)
LET M(1,14)=MOD( M(1,2)+M(1,3)+M(1,4)+M(1,5)+M(1,8)+M(1,9) ,2)
!-----¥¨¥é¡¼¡¦¥Ó¥Ã¥È¤ò¡¢½çÈÖ¤ËÃÖ¤¤¤Æ¤ß¤ë¡££°¡§¥¨¥é¡¼Ìµ¤·¤«¤é£±¡Á£±£´¤Þ¤Ç
FOR j=0 TO 14
CALL error(j)
NEXT j
SUB error(j)
PRINT "-------------------------------------"
PRINT "¸¶·Á¤Î¥á¥Ã¥»¡¼¥¸¡¦¥Ç¡¼¥¿¡¼"
MAT PRINT M;
IF j<>0 THEN
LET back=M(1,j)
PRINT "º¸¤«¤é";j;"ÈÖÌܤΥӥåȤ¬¡¢È¿Å¾¤¹¤ë¤È"
IF M(1,j)=1 THEN LET M(1,j)=0 ELSE LET M(1,j)=1
ELSE
PRINT "Á´¥Ó¥Ã¥Èȿž¤Ê¤±¤ì¤Ð¡¢"
END IF
MAT PRINT M;
!---
CALL check
!---
PRINT "¥Á¥§¥Ã¥¯¡¦¥Ç¡¼¥¿¡¼¤â";bcc(1,1)*8+bcc(1,2)*4+bcc(1,3)*2+bcc(1,4);"¤Ë¤Ê¤ë¡££²¿Ê¿ô"
MAT PRINT bcc;
IF j<>0 THEN LET M(1,j)=back !¸µ¤ØÌ᤹
END SUB
SUB check
MAT bcc=M*h
FOR i=1 TO 4
LET bcc(1,i)=MOD( bcc(1,i), 2)
NEXT i
END SUB
!¥°¥Ã¥É¥¹¥¿¥¤¥ó¤ÎÄêÍý¡ÊR.L.Goodstein¡Ë
!¥¦¥£¥¥Ú¥Ç¥£¥¢¤è¤ê
!http://www.cwi.nl/~tromp/pearls.html#goodstein ¤ÎRubyÈǤò°Ü¿¢
FUNCTION s(b,e,n)
IF n=0 THEN LET s=0 ELSE LET s=MOD(n,b)*(b+1)^s(b,0,e)+s(b,e+1,INT(n/b))
END FUNCTION
FUNCTION g(b,n)
IF n=0 THEN LET g=b ELSE LET g=g(b+1,s(b,0,n)-1)
END FUNCTION
DEF f(n)=g(2,n) !¼«Á³¿ô£î¤ËÂФ¹¤ë£°¤Ë¤Ê¤ë¤È¤¤ÎÄì¤òÊÖ¤¹
PRINT f(0) !f(0)=2,f(1)=3,f(2)=5,f(3)=7
PRINT f(1)
PRINT f(2)
PRINT f(3)
PRINT f(4) !f(4)=3*2^402653211-1¡¡¢¨¥¹¥¿¥Ã¥¯¡¦¥ª¡¼¥Ð¡¼¥Õ¥í¡¼
END
LET t0=TIME
LET N=9 !Ëç¿ô
DIM P(N) !£±¡Á£Î¤Þ¤Ç¤Î¥«¡¼¥É
LET cmax=0
FOR i=N*fact(N-2) TO fact(N)-1 !½çÎó¤òÀ¸À®¤¹¤ë¡¡¢¨£°¡ÁN*(N-2)!-1ÈÖÌܤνçÎó¤Ï¡¢1*****¡¢21****
!FOR i=0 TO fact(N)-1 !½çÎó¤òÀ¸À®¤¹¤ë
CALL Num2Perm(i, P,N)
!!!MAT PRINT P; !debug
LET c=0 !²ó¿ô
DO UNTIL P(1)=1 !¥È¥Ã¥×¤Î¥«¡¼¥É¤¬¡Ö£±¡×¤Þ¤Ç
CALL reverse(P,(P(1))) !¥È¥Ã¥×¤Î¥«¡¼¥É¤Î¿ô»ú¤À¤±¥«¡¼¥É¤òÈ´¤½Ð¤·¡¢½çÈÖ¤òµÕ¤Ë¤·¤Æ¸µ¤ËÌ᤹
LET c=c+1
LOOP
!!!PRINT "²ó¿ô=";c !debug
IF c>cmax THEN !ºÇÂç¤Î¤â¤Î¤òµÏ¿¤¹¤ë
LET cmax=c
LET i_sav=i
END IF
NEXT i
PRINT "ºÇÂç¤Î²ó¿ô=";cmax
CALL Num2Perm(i_sav, P,N) !½çÎó¤òºÆ¸½¤¹¤ë
MAT PRINT P;
PRINT "·×»»»þ´Ö=";TIME-t0
END
EXTERNAL SUB reverse(A(),N) !£±¡Á£Î¤Þ¤Ç¤ÎʤӤòµÕ½ç¤Ë¤¹¤ë
FOR i=1 TO INT(N/2) !¸ò´¹°ÌÃÖ¤ÏȾʬ¤Þ¤Ç¡¡¢¨Á´Éô¤¹¤ë¤È¸µ¤ËÌá¤ë
swap A(i),A(N-i+1) !Ãæ±û¤«¤éÂоΤʰÌÃ֤ɤ¦¤·
NEXT i
END SUB
EXTERNAL SUB Num2Perm(h, A(),N) !Èֹ椫¤é½çÎó¥Ñ¥¿¡¼¥ó¤òÀ¸À®¤¹¤ë¡¡¢¨¼½ñ¼°½ç½ø
LET v=h
FOR j=1 TO N
LET fac=fact(N-j)
LET t=INT(v/fac)
LET A(j)=t+1 !£±¡Á£Î
LET v=v-fac*t
NEXT j
FOR j=N-1 TO 1 STEP -1
FOR k=j+1 TO N
IF A(j)<=A(k) THEN LET A(k)=A(k)+1
NEXT k
NEXT j
END SUB
LET t0=TIME
LET N=13 !£±¡Á£Î¤Î¥«¡¼¥É
DIM P(N)
FOR i=1 TO N !´°Á´À°Îó 1,2,3,4,¡Ä
LET P(i)=i
NEXT i
LET cmax=0 !ºÇ¿¼ê¿ô
DIM P_sav(N) !¤½¤ÎʤÓ
MAT P_sav=P
CALL try(P,N,0,cmax,P_sav)
PRINT "ºÇÂç¤Î²ó¿ô=";cmax
MAT PRINT P_sav;
PRINT "·×»»»þ´Ö=";TIME-t0
END
EXTERNAL SUB reverse(A(),N) !£±¡Á£ÎÈÖÌܤޤǤÎʤӤòµÕ½ç¤Ë¤¹¤ë
FOR i=1 TO INT(N/2) !¸ò´¹°ÌÃÖ¤ÏȾʬ¤Þ¤Ç¡¡¢¨Á´Éô¤¹¤ë¤È¸µ¤ËÌá¤ë
swap A(i),A(N-i+1) !Ãæ±û¤«¤éÂоΤʰÌÃ֤ɤ¦¤·
NEXT i
END SUB
EXTERNAL SUB try(P(),N,c,cmax,P_sav())
DIM W(N)
MAT W=P
FOR i=2 TO N !¸ò´¹¤Ç¤¤Ê¤¯¤Ê¤ë¤Þ¤Ç
MAT P=W
IF P(i)=i THEN !iÈÖÌܤΥ«¡¼¥É¤¬¿ô»úi¤Ê¤é¸ò´¹²Äǽ¡ª¡¡¢¨µÕ¤ÎÁàºî
CALL reverse(P,i) !¥È¥Ã¥×¤Î¥«¡¼¥É¤Î¿ô»ú¤À¤±¥«¡¼¥É¤òÈ´¤½Ð¤·¡¢½çÈÖ¤òµÕ¤Ë¤·¤Æ¸µ¤ËÌ᤹
IF c+1>cmax THEN !ºÇÂç¤Î¤â¤Î¤òµÏ¿¤¹¤ë
LET cmax=c+1
MAT P_sav=P
END IF
CALL try(P,N,c+1,cmax,P_sav) !¼¡¤Ø
END IF
NEXT i
END SUB
!WindowsMe¡¢Pentium·700MHz¡¢192MB¤Ë¤Æ¡¢½½¿ÊBASIC¡¡£²¿Ê¥â¡¼¥É¤Ç¼Â¹Ô¡£
!
!ºÇÂç¤Î²ó¿ô= 80
! 2 9 4 5 11 12 10 1 8 13 3 6 7
!
!·×»»»þ´Ö= 1528.79¡¡¡¡¢«Ìó25.5ʬ
LET t0=TIME
DEF fnFIG(x,n)=MOD(INT(x/10^n),10) !n·åÌܤοô¤òÆÀ¤ë¡¡¢¨0:°ì¤Î°Ì¡¢1:½½¤Î°Ì¡¢2:É´¤Î°Ì¡¢¡Ä
LET N=9 !£±¡Á£¹¤Î¿ô»ú
LET R=3 !º¸Êդηå¿ô
DIM P(R),NM(0 TO 9)
FOR i=0 TO perm(N,R)-1
CALL Num2Perm(i, P,N,R) !º¸ÊÕ¤ò»»½Ð¤¹¤ë
LET x=0
FOR k=1 TO R !¥Û¡¼¥Ê¡¼Ë¡
LET x=x*10+P(k)
NEXT k
LET y=x*x !±¦ÊÕ¤ò»»½Ð¤¹¤ë¡¡¢¨x^2=y¤è¤ê
MAT NM=ZER !½ÅÊ£¤·¤Æ¤¤¤Ê¤¤¤«³Îǧ¤¹¤ë
LET NM(0)=1 !£°
FOR k=1 TO R !º¸ÊÕ¦
LET NM(P(k))=1 !»ÈÍÑÃæ
NEXT k
FOR k=0 TO N-R-1 !±¦ÊÕ¦
LET t=fnFIG(y,k)
IF NM(t)=1 THEN EXIT FOR !½ÅÊ£¡ª
LET NM(t)=1
NEXT k
IF k>N-R-1 THEN PRINT x;"^ 2 =";y !·ë²Ì¤òɽ¼¨¤¹¤ë
NEXT i
PRINT "·×»»»þ´Ö=";TIME-t0
END
EXTERNAL SUB Num2Perm(h, A(),N,R) !Èֹ椫¤é½çÎó¥Ñ¥¿¡¼¥ó¤òÀ¸À®¤¹¤ë¡¡¢¨¼½ñ¼°½ç½ø
LET v=h
FOR j=1 TO R
LET fac=PERM(N-j,R-j)
LET t=INT(v/fac)
LET A(j)=t+1 !£±¡Á£Î
LET v=v-fac*t
NEXT j
FOR j=R-1 TO 1 STEP -1
FOR k=j+1 TO R
IF A(j)<=A(k) THEN LET A(k)=A(k)+1
NEXT k
NEXT j
END SUB
LET t0=TIME
DEF fnFIG(x,n)=MOD(INT(x/10^n),10) !n·åÌܤοô¤òÆÀ¤ë¡¡¢¨0:°ì¤Î°Ì¡¢1:½½¤Î°Ì¡¢2:É´¤Î°Ì¡¢¡Ä
LET N=9 !£±¡Á£¹¤Î¿ô»ú
DIM NM(0 TO 9)
FOR i=INT(SQR(123456789)) TO INT(SQR(987654321))
LET x=i*i !±¦ÊÕ¤ò»»½Ð¤¹¤ë¡¡¢¨x=i^2¤è¤ê
MAT NM=ZER !½ÅÊ£¤·¤Æ¤¤¤Ê¤¤¤«³Îǧ¤¹¤ë
LET NM(0)=1
FOR k=1 TO N !º¸ÊÕ¦
LET t=fnFIG(x,k-1)
IF NM(t)=1 THEN EXIT FOR !½ÅÊ£¡ª
LET NM(t)=1
NEXT k
IF k>N THEN PRINT x;"=";i;"^ 2" !·ë²Ì¤òɽ¼¨¤¹¤ë
NEXT i
PRINT "·×»»»þ´Ö=";TIME-t0
END
!¥¢¥é¥Ó¥¢¿ô»ú¡Ê1,2,3,¡Ä¡Ë¤ò´Á¿ô»ú¡Ê°ì,Æó,»°,¡Ä¡Ë¤ËÊÑ´¹¤¹¤ë¡ÊExcel½àµò¡Ë
LET n1$="¡»°ìÆ󻰻͸ÞÏ»¼·È¬¶å" !´Á¿ô»ú
LET f1$="ÀéÉ´½½¡¡" !°Ì
LET f2$="Ô¶µþÃû²¯Ëü¡¡" !£´·å¤º¤Ä¤Î°Ì
LET n2$="¡»°íÆõ»²»Í¸àÏ»¼·È¬¶å" !Âç»ú
LET f3$="ïôÉ´½¦¡¡" !°Ì
LET f4$="Ô¶µþÃû²¯èß¡¡" !£´·å¤º¤Ä¤Î°Ì
LET n3$="£°£±£²£³£´£µ£¶£·£¸£¹" !¿ô»ú
FUNCTION NumberString$(x,p) !¥¢¥é¥Ó¥¢¿ô»ú¡Ê1,2,3,¡Ä¡Ë¤ò´Á¿ô»ú¡Ê°ì,Æó,»°,¡Ä¡Ë¤ËÊÑ´¹¤¹¤ë
IF x<0 OR x<>INT(x) THEN
PRINT "ÈóÉé¤ÎÀ°¿ô¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£"; x
STOP
ELSE
LET w$=""
SELECT CASE p
CASE 1 !´Á¿ô»ú¤Çɽµ¤¹¤ë
LET a=x
IF a=0 THEN
LET w$="¡»"
ELSE
LET i=LEN(f2$)
DO UNTIL a=0 !¾å°Ì¤Î¿ô»ú¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
LET aa=MOD(a,10000) !¡Ö¡ÄÃû²¯Ëü¡¡¡×¤Î£´·å¤º¤Ä
IF aa<>0 THEN
LET ww$=f2$(i:i)
IF ww$<>"¡¡" THEN LET w$=ww$&w$
LET k=LEN(f1$)
DO UNTIL aa=0 !³Æ¡ÖÀéÉ´½½¡¡¡×¤Î°Ì
LET ww$=f1$(k:k)
IF ww$="¡¡" THEN LET ww$=""
LET t=MOD(aa,10) !°ì¤Î°Ì¤«¤é
IF t=0 THEN !¥¼¥í¡¦¥µ¥×¥ì¥¹
ELSEIF k<LEN(f1$) AND t=1 THEN !£±¡¦¥µ¥×¥ì¥¹
LET w$=ww$&w$
ELSE
LET w$=n1$(t+1:t+1)&ww$&w$
END IF
LET aa=INT(aa/10) !¼¡¤Ø
LET k=k-1
LOOP
END IF
LET a=INT(a/10000) !¼¡¤Ø
LET i=i-1
LOOP
END IF
CASE 2 !Âç»ú¤Î´Á¿ô»ú¤Çɽµ¤¹¤ë
LET a=x
IF a=0 THEN
LET w$="¡»"
ELSE
LET i=LEN(f4$)
DO UNTIL a=0 !¾å°Ì¤Î¿ô»ú¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
LET aa=MOD(a,10000) !¡Ö¡ÄÃû²¯Ëü¡¡¡×¤Î£´·å¤º¤Ä
IF aa<>0 THEN
LET ww$=f4$(i:i)
IF ww$<>"¡¡" THEN LET w$=ww$&w$
LET k=LEN(f3$)
DO UNTIL aa=0 !³Æ¡ÖÀéÉ´½½¡¡¡×¤Î°Ì
LET ww$=f3$(k:k)
IF ww$="¡¡" THEN LET ww$=""
LET t=MOD(aa,10) !°ì¤Î°Ì¤«¤é
IF t=0 THEN !¥¼¥í¡¦¥µ¥×¥ì¥¹
!!!ELSEIF k<LEN(f3$) AND t=1 THEN !£±¡¦¥µ¥×¥ì¥¹
!!! LET w$=ww$&w$
ELSE
LET w$=n2$(t+1:t+1)&ww$&w$
END IF
LET aa=INT(aa/10) !¼¡¤Ø
LET k=k-1
LOOP
END IF
LET a=INT(a/10000) !¼¡¤Ø
LET i=i-1
LOOP
END IF
CASE 3 !¿ôÃͤò¤½¤Î¤Þ¤Þ´Á¿ô»ú¤Çɽµ¤¹¤ë
LET a=x
IF a=0 THEN
LET w$="£°"
ELSE
DO UNTIL a=0 !¾å°Ì¤Î·å¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
LET t=MOD(a,10)+1 !°ì¤Î°Ì¤«¤é
LET w$=n1$(t:t)&w$
LET a=INT(a/10) !¼¡¤Ø
LOOP
END IF
CASE 4 !½½,É´,Àé,Ëü¤Ê¤É¤ò´Á¿ô»ú¤Çɽµ¤¹¤ë
LET a=x
IF a=0 THEN
LET w$="¡»"
ELSE
LET i=LEN(f2$)
DO UNTIL a=0 !¾å°Ì¤Î¿ô»ú¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
LET aa=MOD(a,10000) !¡Ö¡ÄÃû²¯Ëü¡¡¡×¤Î£´·å¤º¤Ä
IF aa<>0 THEN
LET ww$=f2$(i:i)
IF ww$<>"¡¡" THEN LET w$=ww$&w$
LET k=LEN(f1$)
DO UNTIL aa=0 !³Æ¡ÖÀéÉ´½½¡¡¡×¤Î°Ì
LET ww$=f1$(k:k)
IF ww$="¡¡" THEN LET ww$=""
LET t=MOD(aa,10) !°ì¤Î°Ì¤«¤é
IF t=0 THEN !¥¼¥í¡¦¥µ¥×¥ì¥¹
ELSEIF k<LEN(f1$) AND t=1 THEN !£±¡¦¥µ¥×¥ì¥¹
LET w$=ww$&w$
ELSE
LET w$=n3$(t+1:t+1)&ww$&w$
END IF
LET aa=INT(aa/10) !¼¡¤Ø
LET k=k-1
LOOP
END IF
LET a=INT(a/10000) !¼¡¤Ø
LET i=i-1
LOOP
END IF
CASE ELSE
END SELECT
LET NumberString$=w$ !·ë²Ì¤òÊÖ¤¹
END IF
END FUNCTION
!!!PRINT NumberString$(1732050807568877,2) !¢¨1000·å¥â¡¼¥É¡¢ÍÍý¿ô¥â¡¼¥É
PRINT NumberString$(1234567890,1) !½½Æ󲯻°Àé»ÍÉ´¸Þ½½Ï»Ëü¼·ÀéȬɴ¶å½½
PRINT NumberString$(1234567890,2) !°í½¦Æõ²¯»²ïô»ÍÉ´¸à½¦Ï»èß¼·ïôȬɴ¶å½¦
PRINT NumberString$(1234567890,3) !°ìÆ󻰻͸ÞÏ»¼·È¬¶å¡»
PRINT NumberString$(1234567890,4) !½½£²²¯£³À飴ɴ£µ½½£¶Ëü£·À飸ɴ£¹½½
END
!¥Ù¥Ã¥»¥ë´Ø¿ô¤Ç¤¹¤¬¡¢¤³¤Î¥ê¥¹¥È¤Ï¡¢£ø¤ÎÈϰϤ¬¡¢¼Â¿ô¤Þ¤Ç¤Ç¡¢
!Ê£ÁÇ¿ô¤¬»ÈÍѤǤ¤Þ¤»¤ó¡£³ÈÄ¥¤Ç¤¤ëÊý¡¢¤ª´ê¤¤¤·¤Þ¤¹¡£
!
!¢¨½½¿ÊBASIC ¤Ë¤â ¥Ù¥Ã¥»¥ë´Ø¿ô¡¢ÊÑ·Á¥Ù¥Ã¥»¥ë´Ø¿ô£±¼ï¤òÆâÊñ½ÐÍè¤Ê¤¤¤Ç¤·¤ç¤¦¤«¡£
!-------------------------------
OPTION ARITHMETIC NATIVE
OPTION BASE 0
SET TEXT background "opaque"
DIM col(5)
MAT READ col
DATA 4,10,2, 8,8,8 !Red darkGreen Blue Gray Gray Gray
SUB window_i
CLEAR
LET h=4
LET l=-1.5
LET xr=4
SET WINDOW -.1*xr,xr, l,h
DRAW grid(xr/8,h/8)
ASK PIXEL SIZE (0,0; xr,0) j,i
LET dx=xr/j !pitch
END SUB
SUB window_j
CLEAR
LET h=1
LET l=-1
LET xr=20
SET WINDOW -.1*xr,xr, l,h
DRAW grid(xr/4,h/5)
ASK PIXEL SIZE (0,0; xr,0) j,i
LET dx=xr/j !pitch
END SUB
!-------
SUB G_besseli
FOR n=0 TO 2
SET LINE COLOR col(n)
SET TEXT COLOR col(n)
PLOT TEXT,AT .13*xr,h-.08*(h-l)-.04*(h-l)*n :"ÊÑ·Á¥Ù¥Ã¥»¥ë´Ø¿ô£±¼ï "& STR$(n)& "¼¡"
FOR x=dx TO xr+dx STEP dx
LET y=besseli(n,x)
PLOT LINES: x,y; ! PEN-on
IF FP(x)< dx THEN PRINT USING"##.## ###.######":x,y
NEXT x
PLOT LINES !PEN-off
PRINT
NEXT n
END SUB
SUB G_besselj
FOR n=0 TO 2
SET LINE COLOR col(n)
SET TEXT COLOR col(n)
PLOT TEXT,AT .13*xr,h-.08*(h-l)-.04*(h-l)*n :"¥Ù¥Ã¥»¥ë´Ø¿ô£±¼ï "& STR$(n)& "¼¡"
FOR x=dx TO xr+dx STEP dx
LET y=besselj(n,x)
PLOT LINES: x,y; ! PEN-on
IF FP(x)< dx THEN PRINT USING"##.## ###.######":x,y
NEXT x
PLOT LINES !PEN-off
PRINT
NEXT n
END SUB
!-------
FUNCTION besseli(n,x)
LET m=2*INT( (6+MAX(n,1.5*x)+9*1.5*x/(1.5*x+2))/2)
LET w=0
FOR k=1 TO m
LET w=w+Tki(k)
NEXT k
LET besseli=EXP(x)*Tki(n)/(Tki(0)+2*w)
END FUNCTION
FUNCTION Tki(i)
LET t2=0
LET t1=1e-9
LET t0=2*(m+1)/x*t1+t2
FOR kp1=m TO i+1 STEP -1
LET t2=t1
LET t1=t0
LET t0=2*kp1/x*t1+t2
NEXT kp1
LET Tki=t0
END FUNCTION
!-------
FUNCTION besselj(n,x)
LET m=2*INT( (6+MAX(n,1.5*x)+9*1.5*x/(1.5*x+2))/2)
LET w=0
FOR k=1 TO m/2
LET w=w+Tk(k*2)
NEXT k
LET besselj=Tk(n)/(Tk(0)+2*w)
END FUNCTION
FUNCTION Tk(i)
LET t2=0
LET t1=1e-9
LET t0=2*(m+1)/x*t1-t2
FOR kp1=m TO i+1 STEP -1
LET t2=t1
LET t1=t0
LET t0=2*kp1/x*t1-t2
NEXT kp1
LET Tk=t0
END FUNCTION
!¼½ñ¼°½ç½ø¤Ç¼¡¤Î½çÎó¤òÊÖ¤¹
LET N=4
DIM A(N)
DATA 1,2,3,4
!!!DATA 4,3,2,1 !¡¡¢¨Á°¤Î½çÎó¡¡¢«¢«¢«¢«¢«
MAT READ A
MAT PRINT A;
FOR i=1 TO fact(N)
CALL NextPerm(A,N,rc)
PRINT i
IF rc=0 THEN
PRINT "¤¢¤ê¤Þ¤»¤ó¡£"
STOP
END IF
MAT PRINT A;
NEXT i
END
EXTERNAL SUB NextPerm(A(),N, rc) !¼½ñ¼°½ç½ø¤Ç¼¡¤Î½çÎó¤òÊÖ¤¹
LET i=N-1 !½çÎó¤ò±¦¤«¤éº¸¤Ë¤ß¤Æ¡¢Áý²ÃÎ󤫤鸺¾¯Îó¤ËÊѤï¤ë°ÌÃÖi¤òõ¤¹
DO WHILE i>0 AND A(i)>=A(i+1) !£°¤ÏÈÖ¿Í
!!!DO WHILE i>0 AND A(i)<=A(i+1) !£°¤ÏÈÖ¿Í¡¡¢¨Á°¤Î½çÎó¡¡¢«¢«¢«¢«¢«
LET i=i-1
LOOP
IF i=0 THEN !A(1)>A(2)>A(3)> ¡Ä >A(N)¤Ê¤é¡¡Îã. N=4¡¢4,3,2,1
LET rc=0 !´°Î»
EXIT SUB
END IF
LET j=N !¤½¤Î°ÌÃÖi¤è¤ê±¦¤Ç¡¢A(i)°Ê¾å¤ÇºÇ¾®¤Î¿ôA(j)¤òõ¤¹
DO WHILE A(i)>=A(j)
!!!DO WHILE A(i)<=A(j) !¡¡¢¨Á°¤Î½çÎó¡¡¢«¢«¢«¢«¢«
LET j=j-1
LOOP
LET t=A(i) !A(i)¤ÈA(j)¤ò¸ò´¹¤¹¤ë
LET A(i)=A(j)
LET A(j)=t
LET i=i+1 !(i+1)¤«¤éN¤Þ¤Ç¤ÎÈϰϤòµÕ½ç¤Ë¤¹¤ë
LET j=N
DO WHILE i<j
LET t=A(i) !swap it
LET A(i)=A(j)
LET A(j)=t
LET i=i+1
LET j=j-1
LOOP
LET rc=1 !̤λ
END SUB
!ȿžÁàºî¤Ë¤è¤ë¥Ö¥í¥Ã¥¯°ÜÆ°
LET N=15 !Ëç¿ô
DIM A(N) !¥«¡¼¥É¤ÎʤÓ
PRINT "£²Ê¬³ä¤Î¾ì¹ç"
FOR i=1 TO N !À°Îó
LET A(i)=i
NEXT i
MAT PRINT A;
LET p=5 !°ÌÃÖ
CALL reverse(A,1,p-1) !Á°È¾Éôʬ¤Î¤ß
MAT PRINT A;
CALL reverse(A,p,N) !¸åȾÉôʬ¤Î¤ß
MAT PRINT A;
CALL reverse(A,1,N) !Á´ÂΤÇ
MAT PRINT A;
PRINT
PRINT "£³Ê¬³ä¤Î¾ì¹ç"
FOR i=1 TO N !À°Îó
LET A(i)=i
NEXT i
MAT PRINT A;
LET p=7 !°ÌÃÖ
LET q=12
CALL reverse(A,1,p-1) !Á°È¾Éôʬ¤Î¤ß
MAT PRINT A;
CALL reverse(A,p,q-1) !Ãæ±ûÉôʬ¤Î¤ß
MAT PRINT A;
CALL reverse(A,q,N) !¸åȾÉôʬ¤Î¤ß
MAT PRINT A;
CALL reverse(A,1,N) !Á´ÂΤÇ
MAT PRINT A;
END
EXTERNAL SUB reverse(A(),L,R) !»ØÄꤵ¤ì¤¿ÈϰϤÎʤӤòµÕ½ç¤Ë¤¹¤ë
LET i=L !º¸Ã¼
LET j=R !±¦Ã¼
DO WHILE i<j !¸ò´¹°ÌÃÖ¤ÏȾʬ¤Þ¤Ç¡¡¢¨Á´Éô¤¹¤ë¤È¸µ¤ËÌá¤ë
LET t=A(i) !swap it
LET A(i)=A(j)
LET A(j)=t
LET i=i+1 !¼¡¤Ø
LET j=j-1
LOOP
END SUB
!Jn(z)=(1/¦Ð)*¢é[0,¦Ð]{cos(n*¦È-z*sin¦È)}d¦È ÀÑʬɽ¼¨¤è¤ê¡¢¿ôÃÍÀÑʬ¤Çµá¤á¤ë
!¡Ê¸¡»»¤Ë»È¤Ã¤¿¡Ë»²¹Í¥µ¥¤¥È¡¡http://keisan.casio.jp/
OPTION ARITHMETIC COMPLEX
LET j=SQR(-1) !µõ¿ôñ°Ì
DEF SIN(z)=(EXP(j*z)-EXP(-j*z))/(2*j) !»°³Ñ´Ø¿ô
DEF COS(z)=(EXP(j*z)+EXP(-j*z))/2
FUNCTION complexbessel(n,z) !£±¼ï¥Ù¥Ã¥»¥ë´Ø¿ô Jn(x+i*y)
LET div=1000 !ʬ³ä¿ô
LET u=0
LET h=PI/div
LET a=0
FOR i=1 TO div !¿ôÃÍÀÑʬ¤ÎÂæ·Á¸ø¼°
LET u=u+( COS(n*a-z*SIN(a)) + COS(n*(a+h)-z*SIN(a+h)) )/2
LET a=h*i
NEXT i
LET complexbessel=h*u/PI
END FUNCTION
SET WINDOW -0.1*20,20, -1,1 !ɽ¼¨ÈÏ°Ï
DRAW grid(20/4,1/5)
LET dx=0.2 !¥°¥é¥Õ¤ÎÉÁ²è´Ö³Ö
FOR n=0 TO 2
SET LINE COLOR n+2
SET TEXT COLOR n+2
PLOT TEXT,AT .13*20,1-.08*2-.04*2*n :"¥Ù¥Ã¥»¥ë´Ø¿ô£±¼ï "& STR$(n)& "¼¡"
FOR x=0 TO 20 STEP dx
LET y=Re( complexbessel(n,COMPLEX(x,0)) ) !¼Â¿ô
PLOT LINES: x,y;
IF FP(x)< dx THEN PRINT USING"##.## ###.######": x,y
NEXT x
PLOT LINES
PRINT
NEXT n
END
SUB window_i
CLEAR
LET h=4
LET l=-1.5
LET xr=4
SET WINDOW -.1*xr,xr, l,h
DRAW grid(xr/8,h/8)
ASK PIXEL SIZE (0,0; xr,0) j,i
LET dx=xr/j !pitch
END SUB
SUB window_j
CLEAR
LET h=1
LET l=-1
LET xr=20
SET WINDOW -.1*xr,xr, l,h
DRAW grid(xr/4,h/5)
ASK PIXEL SIZE (0,0; xr,0) j,i
LET dx=xr/j !pitch
END SUB
!-------
SUB G_besseli
FOR n=0 TO 2
SET LINE COLOR col(n)
SET TEXT COLOR col(n)
PLOT TEXT,AT .13*xr,h-.08*(h-l)-.04*(h-l)*n :"ÊÑ·Á¥Ù¥Ã¥»¥ë´Ø¿ô£±¼ï "& STR$(n)& "¼¡"
FOR t=dx TO xr+dx STEP dx
LET x=t
LET y=besseli(n,x)
! LET x=COMPLEX(0,t)
! LET y=COMPLEX(0,1)^(-n)*besseli(n,x)
PLOT LINES: ABS(x),y; ! PEN-on
IF FP(t)< dx THEN PRINT x;y
NEXT t
PLOT LINES !PEN-off
PRINT
NEXT n
END SUB
SUB G_besselj
FOR n=0 TO 2
SET LINE COLOR col(n+3)
SET TEXT COLOR col(n+3)
PLOT TEXT,AT .13*xr,h-.08*(h-l)-.04*(h-l)*n :"¥Ù¥Ã¥»¥ë´Ø¿ô£±¼ï "& STR$(n)& "¼¡¡¡¡¡"
FOR t=dx TO xr+dx STEP dx
! LET x=t
! LET y=besselj(n,x)
LET x=COMPLEX(0,t)
LET y=COMPLEX(0,1)^(-n)*besselj(n,x)
PLOT LINES: ABS(x),y; ! PEN-on
IF FP(t)< dx THEN PRINT x;y
NEXT t
PLOT LINES !PEN-off
PRINT
NEXT n
END SUB
!-------
FUNCTION besseli(n,x)
IF x=0 THEN LET x=1e-32 !£°¤ÎÊݸî( ¾ì¹ç¤Ë¤è¤ê³°¤¹)
LET m=2*INT( (6+MAX(n,1.5*ABS(x))+9*1.5*ABS(x)/(1.5*ABS(x)+2))/2 )
LET w=0
FOR k=1 TO m
LET w=w+Tki(k,x)
NEXT k
LET besseli=EXP(x)*Tki(n,x)/(Tki(0,x)+2*w)
END FUNCTION
FUNCTION Tki(i,x)
LET t2=0
LET t1=1e-9
LET t0=2*(m+1)/x*t1+t2
FOR kp1=m TO i+1 STEP -1
LET t2=t1
LET t1=t0
LET t0=2*kp1/x*t1+t2
NEXT kp1
LET Tki=t0
END FUNCTION
!-------
FUNCTION besselj(n,x)
IF x=0 THEN LET x=1e-32 !£°¤ÎÊݸî( ¾ì¹ç¤Ë¤è¤ê³°¤¹)
LET m=2*INT( (6+MAX(n,1.5*ABS(x))+9*1.5*ABS(x)/(1.5*ABS(x)+2))/2 )
LET w=0
FOR k=1 TO m/2
LET w=w+Tk(k*2,x)
NEXT k
LET besselj=Tk(n,x)/(Tk(0,x)+2*w)
END FUNCTION
FUNCTION Tk(i,x)
LET t2=0
LET t1=1e-9
LET t0=2*(m+1)/x*t1-t2
FOR kp1=m TO i+1 STEP -1
LET t2=t1
LET t1=t0
LET t0=2*kp1/x*t1-t2
NEXT kp1
LET Tk=t0
END FUNCTION
!------
SUB msub00
SET WINDOW -a*1.01,a*1.01, -0.01,+1.01
PLOT AREA:-a*1.01,-0.01;a*1.01,-0.01;a*1.01,1.01;-a*1.01,1.01
DRAW axes0( a/5, 0.2)
ASK PIXEL SIZE(-a,0;a,0) j,i
LET dr=2*a/j
PRINT USING "¦Õ= %.##mm": a*2000
FOR ch=1 TO 6
CALL skin
NEXT ch
END SUB
!------ ÊÑ·Á¥Ù¥Ã¥»¥ë´Ø¿ô£±¼ï£°¼¡
FUNCTION besseli(n,x)
LET m=2*INT( (6+MAX(n,1.5*ABS(x))+9*1.5*ABS(x)/(1.5*ABS(x)+2))/2)
LET w=0
FOR kk=1 TO m
LET w=w+Tki(kk,x)
NEXT kk
LET besseli=EXP(x)*Tki(n,x)/(Tki(0,x)+2*w)
END FUNCTION
FUNCTION Tki(i,x)
LET t2=0
LET t1=1e-9
LET t0=2*(m+1)/x*t1+t2
FOR kp1=m TO i+1 STEP -1
LET t2=t1
LET t1=t0
LET t0=2*kp1/x*t1+t2
NEXT kp1
LET Tki=t0
END FUNCTION
LET N=4 !N·å¤Î³¬¾è¿Ê¿ô
DIM A(N) !³Æ·å¤ÎÃÍ¡¢½çÎó
FOR i=0 TO FACT(N)-1 !¾ì¹ç¤Î¿ô
PRINT "i="; i !·ë²Ì¤òɽ¼¨¤¹¤ë
CALL Num2Factoradic(i, A,N) !³¬¾è¿Ê¿ô¤Ø
MAT PRINT A;
PRINT Factoradic2Num(A,N) !¸¡»»
CALL Num2PermFactorial(i,A,N) !½çÎó¤Ø
MAT PRINT A;
PRINT PermFactorial2Num(A,N) !¸¡»»
NEXT i
END
EXTERNAL FUNCTION Factoradic2Num(A(),N) !N·å¤Î³¬¾è¿Ê¿ô¤ËÂФ·¤Æ¡¢ÈóÉéÀ°¿ô¤òµá¤á¤ë
FOR j=N TO 1 STEP -1
LET v=v*j+A(N-j+1) !³¬¾è¿Ê¿ô¤Î³Æ·å¤ÎÃÍ¡¡A[1..N]=(N-1)! ¡Ä 3! 2! 1! 0!
NEXT j
LET Factoradic2Num=v
END FUNCTION
EXTERNAL SUB Num2Factoradic(K, A(),N) !ÈóÉéÀ°¿ôK¤ËÂФ·¤Æ¡¢N·å¤Î³¬¾è¿Ê¿ô¤òµá¤á¤ë
LET v=K
FOR j=1 TO N
LET A(N-j+1)=MOD(v,j) !³¬¾è¿Ê¿ô¤Î³Æ·å¤ÎÃÍ¡¡A[1..N]=(N-1)! ¡Ä 3! 2! 1! 0!
LET v=INT(v/j)
NEXT j
END SUB
!n!¤Î½çÎó¥Ñ¥¿¡¼¥ó ¢Î 0¡Á(n!-1)¤ÎÈÖ¹æ
EXTERNAL FUNCTION PermFactorial2Num(A(),N) !½çÎó¥Ñ¥¿¡¼¥ó¤ËÈÖ¹æ¤òÉÕ¤±¤ë¡¡¢¨¼½ñ¼°½ç½ø
FOR j=1 TO N-1 !³¬¾è¿Ê¿ô¤Î³Æ·å¤ÎÃÍ¡Ü£±¡¡A[1..N]=(N-1)! ¡Ä 3! 2! 1! 0!
FOR k=j+1 TO N
IF A(k)>=A(j) THEN LET A(k)=A(k)-1
NEXT k
NEXT j
LET v=0
FOR j=N TO 1 STEP -1 !ÈóÉé¤Î10¿Ê¿ôÀ°¿ô¤Ø
LET v=v*j+A(N-j+1)-1
NEXT j
LET PermFactorial2Num=v
END FUNCTION
EXTERNAL SUB Num2PermFactorial(h, A(),N) !Èֹ椫¤é½çÎó¥Ñ¥¿¡¼¥ó¤òÀ¸À®¤¹¤ë¡¡¢¨¼½ñ¼°½ç½ø
LET v=h !ÈóÉé¤Î10¿Ê¿ôÀ°¿ô¤ò³¬¾è¿Ê¿ô¤Ø
FOR j=1 TO N
LET A(N-j+1)=MOD(v,j)+1 !³¬¾è¿Ê¿ô¤Î³Æ·å¤ÎÃÍ¡Ü£±¡¡A[1..N]=(N-1)! ¡Ä 3! 2! 1! 0!
LET v=INT(v/j)
NEXT j
FOR j=N-1 TO 1 STEP -1 !½çÎó¥Ñ¥¿¡¼¥ó¤Ø
FOR k=j+1 TO N
IF A(k)>=A(j) THEN LET A(k)=A(k)+1
NEXT k
NEXT j
END SUB
EXTERNAL FUNCTION Perm2Num(A(),N,R) !½çÎó¥Ñ¥¿¡¼¥ó¤ËÈÖ¹æ¤òÉÕ¤±¤ë¡¡¢¨¼½ñ¼°½ç½ø
FOR j=1 TO R-1 !(³¬¾è)¿Ê¿ô¤Î³Æ·å¤ÎÃÍ¡Ü£±¡¡A[1..R]=PERM(N-1,R-1) ¡Ä PERM(N-j,R-j) ¡Ä PERM(N-R,0)
FOR k=j+1 TO R
IF A(k)>=A(j) THEN LET A(k)=A(k)-1
NEXT k
NEXT j
LET v=0
FOR j=R TO 1 STEP -1 !ÈóÉé¤Î10¿Ê¿ôÀ°¿ô¤Ø
LET v=v*(N-R+j)+A(R-j+1)-1
NEXT j
LET Perm2Num=v
END FUNCTION
EXTERNAL SUB Num2Perm(h, A(),N,R) !Èֹ椫¤é½çÎó¥Ñ¥¿¡¼¥ó¤òÀ¸À®¤¹¤ë¡¡¢¨¼½ñ¼°½ç½ø
LET v=h !ÈóÉé¤Î10¿Ê¿ôÀ°¿ô¤ò(³¬¾è)¿Ê¿ô¤Ø
FOR j=1 TO R
LET A(R-j+1)=MOD(v,N-R+j)+1 !(³¬¾è)¿Ê¿ô¤Î³Æ·å¤ÎÃÍ¡Ü£±¡¡A[1..R]=PERM(N-1,R-1) ¡Ä PERM(N-j,R-j) ¡Ä PERM(N-R,0)
LET v=INT(v/(N-R+j))
NEXT j
FOR j=R-1 TO 1 STEP -1 !½çÎó¥Ñ¥¿¡¼¥ó¤Ø
FOR k=j+1 TO R
IF A(k)>=A(j) THEN LET A(k)=A(k)+1
NEXT k
NEXT j
END SUB
FUNCTION NumberString2$(x,p) !¥¢¥é¥Ó¥¢¿ô»ú¡Ê1,2,3,¡Ä¡Ë¤ò´Á¿ô»ú¡Ê°ì,Æó,»°,¡Ä¡Ë¤ËÊÑ´¹¤¹¤ë
IF x<0 THEN
PRINT "ÈóÉé¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£"; x
STOP
ELSE
LET w$=""
SELECT CASE p
CASE 1 !´Á¿ô»ú¤Çɽµ¤¹¤ë
LET a=INT(x) !!
IF a=0 THEN
LET w$="¡»"
ELSE
LET i=LEN(f2$)
DO UNTIL a=0 !¾å°Ì¤Î¿ô»ú¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
LET aa=MOD(a,10000) !¡Ö¡ÄÃû²¯Ëü¡¡¡×¤Î£´·å¤º¤Ä
IF aa<>0 THEN
LET ww$=f2$(i:i)
IF
ww$<>"¡¡" THEN LET w$=ww$&w$
LET k=LEN(f1$)
DO
UNTIL aa=0 !³Æ¡ÖÀéÉ´½½¡¡¡×¤Î°Ì
LET ww$=f1$(k:k)
IF ww$="¡¡" THEN LET ww$=""
LET t=MOD(aa,10) !°ì¤Î°Ì¤«¤é
IF t=0 THEN !¥¼¥í¡¦¥µ¥×¥ì¥¹
ELSEIF k<LEN(f1$) AND t=1 THEN !£±¡¦¥µ¥×¥ì¥¹
LET
w$=ww$&w$
ELSE
LET
w$=n1$(t+1:t+1)&ww$&w$
END IF
LET aa=INT(aa/10) !¼¡¤Ø
LET k=k-1
LOOP
END IF
LET a=INT(a/10000) !¼¡¤Ø
LET i=i-1
LOOP
END IF
CASE 2 !Âç»ú¤Î´Á¿ô»ú¤Çɽµ¤¹¤ë
LET a=INT(x) !!
IF a=0 THEN
LET w$="¡»"
ELSE
LET i=LEN(f4$)
DO UNTIL a=0 !¾å°Ì¤Î¿ô»ú¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
LET aa=MOD(a,10000) !¡Ö¡ÄÃû²¯Ëü¡¡¡×¤Î£´·å¤º¤Ä
IF aa<>0 THEN
LET ww$=f4$(i:i)
IF
ww$<>"¡¡" THEN LET w$=ww$&w$
LET k=LEN(f3$)
DO
UNTIL aa=0 !³Æ¡ÖÀéÉ´½½¡¡¡×¤Î°Ì
LET ww$=f3$(k:k)
IF ww$="¡¡" THEN LET ww$=""
LET t=MOD(aa,10) !°ì¤Î°Ì¤«¤é
IF t=0 THEN !¥¼¥í¡¦¥µ¥×¥ì¥¹
!!!ELSEIF k<LEN(f3$) AND t=1 THEN !£±¡¦¥µ¥×¥ì¥¹
!!! LET w$=ww$&w$
ELSE
LET
w$=n2$(t+1:t+1)&ww$&w$
END IF
LET aa=INT(aa/10) !¼¡¤Ø
LET k=k-1
LOOP
END IF
LET a=INT(a/10000) !¼¡¤Ø
LET i=i-1
LOOP
END IF
CASE 3 !¿ôÃͤò¤½¤Î¤Þ¤Þ´Á¿ô»ú¤Çɽµ¤¹¤ë
LET a=INT(x) !!
IF a=0 THEN
LET w$="¡»" !!
ELSE
DO UNTIL a=0 !¾å°Ì¤Î·å¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
LET t=MOD(a,10)+1 !°ì¤Î°Ì¤«¤é
LET w$=n1$(t:t)&w$
LET a=INT(a/10) !¼¡¤Ø
LOOP
END IF
CASE 4 !½½,É´,Àé,Ëü¤Ê¤É¤ò´Á¿ô»ú¤Çɽµ¤¹¤ë
LET a=INT(x) !!
IF a=0 THEN
LET w$="£°" !!
ELSE
LET i=LEN(f2$)
DO UNTIL a=0 !¾å°Ì¤Î¿ô»ú¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
LET aa=MOD(a,10000) !¡Ö¡ÄÃû²¯Ëü¡¡¡×¤Î£´·å¤º¤Ä
IF aa<>0 THEN
LET ww$=f2$(i:i)
IF
ww$<>"¡¡" THEN LET w$=ww$&w$
LET k=LEN(f1$)
DO
UNTIL aa=0 !³Æ¡ÖÀéÉ´½½¡¡¡×¤Î°Ì
LET ww$=f1$(k:k)
IF ww$="¡¡" THEN LET ww$=""
LET t=MOD(aa,10) !°ì¤Î°Ì¤«¤é
IF t=0 THEN !¥¼¥í¡¦¥µ¥×¥ì¥¹
ELSEIF k<LEN(f1$) AND t=1 THEN !£±¡¦¥µ¥×¥ì¥¹
LET
w$=ww$&w$
ELSE
LET
w$=n3$(t+1:t+1)&ww$&w$
END IF
LET aa=INT(aa/10) !¼¡¤Ø
LET k=k-1
LOOP
END IF
LET a=INT(a/10000) !¼¡¤Ø
LET i=i-1
LOOP
END IF
CASE 5 !! Ãû,²¯,Ëü¤Ê¤É¤ò´Á¿ô»ú¤Çɽµ¤¹¤ë
LET a=INT(x)
IF a=0 THEN
LET w$="£°"&w$
ELSE
LET i=LEN(f2$)
DO UNTIL a=0 !¾å°Ì¤Î¿ô»ú¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
LET aa=MOD(a,10000) !¡Ö¡ÄÃû²¯Ëü¡¡¡×¤Î£´·å¤º¤Ä
IF aa<>0 THEN
LET ww$=f2$(i:i)
IF
ww$<>"¡¡" THEN LET w$=ww$&w$
DO
UNTIL aa=0 !³Æ¡ÖÀéÉ´½½¡¡¡×¤Î°Ì
LET t=MOD(aa,10) !°ì¤Î°Ì¤«¤é
LET w$=n3$(t+1:t+1)&w$
LET aa=INT(aa/10) !¼¡¤Ø
LOOP
END IF
LET a=INT(a/10000) !¼¡¤Ø
LET i=i-1
LOOP
END IF !!
CASE ELSE
END SELECT
IF x<>INT(x) THEN !!
IF INT(x)=0 THEN
LET w$=""
ELSEIF p=1 OR p=2 OR p=4 THEN
LET w$=w$&"¡¦"
END IF
LET w$=w$&NumberString3$(FP(x),p) ! ¾®¿ôÉôÊÑ´¹
END IF !!
LET NumberString2$=w$ !·ë²Ì¤òÊÖ¤¹
END IF
END FUNCTION
!³¤¯
!³¤
FUNCTION NumberString3$(x,p) !¥¢¥é¥Ó¥¢¿ô»ú¾®¿ôÉô¡Ê.123¡Ä¡Ë¤ò´Á¿ô»ú¡Ê°ìʬÆóÎÒ»°ÌӡġˤËÊÑ´¹¤¹¤ë
IF x<=0 OR x>=1 THEN
PRINT "Àµ¤Î¾®¿ô(0<x<1)¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£"; x
STOP
END IF
LET b=x
LET ww$=""
LET k=1
SELECT CASE p
CASE 1 !´Á¿ô»ú¤Çɽµ¤¹¤ë(°ìʬÆóÎÒ»°ÌÓ)
DO UNTIL b=0 !¾®¿ô¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
LET t=INT(10*b)
WHEN EXCEPTION IN
LET ff2$=ff$(k) ! ÇÛÎóź»ú¥ª¡¼¥Ð¡¼¤ÇÎ㳰ȯÀ¸
IF t<>0 THEN LET ww$=ww$&n1$(t+1:t+1)&ff2$
USE
LET ww$=ww$&n1$(t+1:t+1) ! t=0¤òɽµ
END WHEN
LET b=10*b-t !¼¡¤Ø
LET k=k+1
LOOP
CASE 2 !Âç»ú¤Î´Á¿ô»ú¤Çɽµ¤¹¤ë(°íʬÆõÎÒ»²ÌÓ)
DO UNTIL b=0 !¾®¿ô¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
LET t=INT(10*b)
WHEN EXCEPTION IN
LET ff2$=ff$(k)
IF
t<>0 THEN LET ww$=ww$&n2$(t+1:t+1)&ff$(k)
USE
LET ww$=ww$&n2$(t+1:t+1)
END WHEN
LET b=10*b-t !¼¡¤Ø
LET k=k+1
LOOP
CASE 3 !¿ôÃͤò¤½¤Î¤Þ¤Þ´Á¿ô»ú¤Çɽµ¤¹¤ë(¡¦°ìÆó»°)
LET ww$="¡¦" ! Ãæ¹õ
DO UNTIL b=0 !¾®¿ô¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
LET t=INT(10*b)
LET ww$=ww$&n1$(t+1:t+1)
LET b=10*b-t !¼¡¤Ø
LOOP
CASE 4 !ʬ,ÎÒ,ÌÓ,»å¤Ê¤É¤ò´Á¿ô»ú¤Çɽµ¤¹¤ë(£±Ê¬£²ÎÒ£³ÌÓ)
DO UNTIL b=0 !¾®¿ô¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
LET t=INT(10*b)
WHEN EXCEPTION IN
LET ff2$=ff$(k)
IF
t<>0 THEN LET ww$=ww$&n3$(t+1:t+1)&ff$(k)
USE
LET ww$=ww$&n3$(t+1:t+1)
END WHEN
LET b=10*b-t !¼¡¤Ø
LET k=k+1
LOOP
CASE 5 !Á´³Ñ¿ô»ú¤Çɽµ¤¹¤ë(¡¥£±£²£³)
LET ww$="¡¥" ! Á´³Ñ¥Ô¥ê¥ª¥É
DO UNTIL b=0 !¾®¿ô¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
LET t=INT(10*b)
LET ww$=ww$&n3$(t+1:t+1)
LET b=10*b-t !¼¡¤Ø
LOOP
CASE ELSE
END SELECT
LET NumberString3$=ww$ !·ë²Ì¤òÊÖ¤¹
END FUNCTION
PRINT NumberString2$(1234567890.1204,1) !½½Æ󲯻°Àé»ÍÉ´¸Þ½½Ï»Ëü¼·ÀéȬɴ¶å½½¡¦°ìʬÆóÎһͻå
PRINT NumberString2$(1234567890.1204,2) !°í½¦Æõ²¯»²ïô»ÍÉ´¸à½¦Ï»)èß¼·ïôȬɴ¶å½¦¡¦°íʬÆõÎһͻå
PRINT NumberString2$(1234567890.1204,3) !°ìÆ󻰻͸ÞÏ»¼·È¬¶å¡»¡¦°ìÆó¡»»Í
PRINT NumberString2$(1234567890.1204,4) !½½£²²¯£³À飴ɴ£µ½½£¶Ëü£·À飸ɴ£¹½½¡¦£±Ê¬£²ÎÒ£´»å
PRINT NumberString2$(1234567890.1204,5) !£±£²²¯£³£´£µ£¶Ëü£·£¸£¹£°¡¥£±£²£°£´
PRINT
DIM x(4)
FOR p=1 TO 5
PRINT NumberString2$(PI,p)
NEXT p
PRINT
LET x(1)=5000021007
LET x(2)=.023006
LET x(3)=48130000000
LET x(4)=7.31650080029041875E23 !¢¨1000·å¥â¡¼¥É¡¢ÍÍý¿ô¥â¡¼¥É
FOR p=1 TO 5
FOR ii=1 TO 4
PRINT NumberString2$(x(ii),p),
NEXT ii
PRINT
NEXT p
END
170 FUNCTION String_to_Num(w$)
180 DO
190 LET i=MAX(POS(w$," "),POS(w$,"¡¡"))
200 LET w$(i:i)=""
210 LOOP UNTIL i=0
220 FOR i=1 TO LEN(w$)
230 FOR p=1 TO 4 ! Á´³Ñ¿ô»ú/´Á¿ô»ú¤òȾ³Ñ»»ÍÑ¿ô»ú¤Ë
240 FOR j=0 TO 9
250 IF w$(i:i)=nk$(p,j) THEN LET w$(i:i)=STR$(j)
260 NEXT j
270 NEXT p
280 IF w$(i:i)="ïô" OR w$(i:i)="ÐÂ" THEN LET w$(i:i)="Àé"
290 IF w$(i:i)="ïù" OR w$(i:i)="ÐÑ" THEN LET w$(i:i)="É´"
300 IF w$(i:i)="½¦" THEN LET w$(i:i)="½½"
310 NEXT i
320 LET i=POS(w$,"èß")
330 IF i>0 THEN LET w$(i:i)="Ëü"
340 LET i=POS(w$,"6ÆÁ")
350 IF i>0 THEN LET w$(i:i+1)="Ï»ÆÁ"
360 LET pt=POS(w$,"¡¥")+POS(w$,".")+POS(w$,"¡¦")
370 IF pt>0 THEN
380 LET w$(pt:pt)="."
390 LET len_int=pt-1 ! À°¿ôÉôʸ»ú¿ô
400 ELSE
410 LET len_int=LEN(w$)
420 END IF
! print w$
!
430 WHEN EXCEPTION IN
440 LET num=VAL(w$)
450 LET String_to_Num=num ! "°ìÆ󻰻͸ޡ¦Ï»¼·"(¿ô»ú¤Î¤ß)
460 EXIT FUNCTION
470 USE
480 END WHEN
!
490 LET num=i_val(w$) ! À°¿ôÉôÊÑ´¹
!
500 IF pt>0 THEN
510 LET f$=w$(pt:LEN(w$))
520 WHEN EXCEPTION IN
530 LET num=num+VAL(f$)
540 LET String_to_Num=num ! "£±£²Ëü£³£´£µ£¶¡¥£·£¸"(¾®¿ôÉô¤¬¿ô»ú¤Î¤ß)
550 USE
560 LET String_to_Num=num+f_val(f$(2:LEN(f$))) ! "½½Æ󡦻°Ê¬»ÍÎÒ"(À°¿ô¾®¿ô¤¢¤ê)
570 END WHEN
580 ELSEIF num=0 AND LEN(w$)>=2 THEN
590 LET String_to_Num=f_val(w$) ! "°ìʬÆóÎÒ»°Ìӻͻå"(¾®¿ôÉô¤Î¤ß)
600 ELSE
610 LET String_to_Num=num ! "É´Æó½½»°"(À°¿ôÉô¤Î¤ß)
620 END IF
630 END FUNCTION
!
640 FUNCTION i_val(w$) ! À°¿ôÉôÊÑ´¹
650 LET num=0
660 LET k0=1
670 FOR i=1 TO SIZE(f2$)
680 LET k2=POS(w$,f2$(i),k0+1) ! Ô¶,µþ,Ãû,²¯,Ëü
690 IF k2>0 THEN
700 LET num=num+val1000(w$(k0:k2-1))*10000^(SIZE(f2$)-i+1) ![ÀéÉ´½½°ì]¤Î4·å
710 LET k0=k2+1
720 END IF
730 NEXT i
740 IF k0<=len_int THEN ! ºÇ²¼°Ì4·å
750 LET num=num+val1000(w$(k0:len_int))
760 END IF
770 LET i_val=num
780 END FUNCTION
!
790 FUNCTION val1000(aa$) ! [ÀéÉ´½½°ì]¤Î4·åÊÑ´¹
800 WHEN EXCEPTION IN
810 LET aa=VAL(aa$)
820 LET val1000=aa
830 EXIT FUNCTION
840 USE
850 END WHEN
860 LET aa=0
870 LET kk=1
880 FOR j=1 TO 3
890 LET k1=POS(aa$,f1$(j),kk) ! Àé,É´,½½
900 IF k1>0 THEN
910 WHEN EXCEPTION IN
920 LET aa=aa+VAL(aa$(k1-1:k1-1))*10^(4-j)
930 USE
940 LET aa=aa+10^(4-j) ! ·¸¿ô"1"¤Î¾Êά»þ(3ÀéÉ´4½½5¤Ê¤É)
950 END WHEN
960 LET kk=k1+1
970 END IF
980 NEXT j
990 IF kk=LEN(aa$) THEN LET aa=aa+VAL(aa$(kk:kk)) ! °ì
1000 LET val1000=aa
1010 END FUNCTION
!
1020 FUNCTION f_val(f$) ! ¾®¿ôÉôÊÑ´¹
1030 LET frac=0
1040 LET k0=1
1050 FOR i=1 TO SIZE(ff$)
1060 IF ff$(i)<>"" THEN
1070 LET fd=POS(f$,ff$(i),k0+1)
1080 IF fd>0 THEN
1090 LET frac=frac+VAL(f$(fd-1:fd-1))*10^(-i)
1100 LET k0=fd+LEN(ff$(i))
1110 LET k3=i
1120 END IF
1130 END IF
1140 NEXT i
1150 WHEN EXCEPTION IN
1160 IF k0<=LEN(f$) THEN
1170 LET frac=frac+VAL(f$(k0:LEN(f$)))*10^(-(k3+LEN(f$)-k0+1))
1180 END IF
1190 USE
1200 END WHEN
1210 LET f_val=frac
1220 END FUNCTION
!
1230 END
220 point -10:word -40:M=1850:dim C(M):C(0)=1:S=1/2+14#i
250 for K=1 to M:for J=K to 1 step -1:C(J)=(C(J)+C(J-1))/2:next:next
300 ' find zeta zero
330 repeat
350 Z=fnZeta(S):H=Z/S:W=fnZeta(S+H):S+=H/(1-W/Z)
360 print using(8,20),S
380 until abs(Z)<1/10^18
390 end
800 ' zeta function
810 fnZeta(X)
820 local J,U
830 for J=1 to M:U+=(-1)^(J-1)*C(J)/J^X:next:U/=1-2^(1-X)
880 return(U)
OPTION ARITHMETIC COMPLEX
OPTION BASE 0
!
!point -10 !ÊÑ¿ô¤Î¾®¿ôÉô 10*4.8·å ÀßÄêÉԲġ£
!
!word -40 !ÊÑ¿ô¤ÎŤµ 40*4.8·å ÀßÄêÉԲġ£
LET
M=1850
!¢¨Ã»¤¯¤Æ¤âÆâÉô·×»»¤Ï¾ï¤Ë2600·å¡£
DIM C(M)
LET C(0)=1
LET S=COMPLEX(1/2,14) !S=1/2+14#i
FOR K=1 TO M
FOR J=K TO 1 STEP -1
LET C(J)=(C(J)+C(J-1))/2
NEXT J
NEXT K
!' find zeta zero
DO !repeat
LET
Z=Zeta(S) !Z=fnZeta(S)
LET H=Z/S
LET
W=Zeta(S+H) !W=fnZeta(S+H)
LET S=S+H/(1-W/Z) !S+=H/(1-W/Z)
PRINT
S !print
using(8,20),S
! PRINT USING "########.#################### ########.####################":re(S),im(S);
! PRINT "#i"
LOOP UNTIL ABS(Z)< 1e-12 ! 1e-14 !until abs(Z)< 1/10^18 !½½¿ÊBASIC¤Ç ^18¤Ï̵Íý¡£
STOP !END
!' zeta function
FUNCTION
Zeta(X) !fnZeta(X)
¢¨'fn'¤Ï¡¢¥æ¡¼¥¶¡¼ÄêµÁ´Ø¿ô ÀÜƬ¸ì
local J,U
FOR J=1 TO M
LET U=U+(-1)^(J-1)*C(J)/J^X !U+=(-1)^(J-1)*C(J)/J^X
NEXT J
LET U=U/(1-2^(1-X)) !U/=1-2^(1-X)
LET
Zeta=U
!return(U)
END FUNCTION
OPTION ARITHMETIC DECIMAL_HIGH
220 ! point -10:word -40
DECLARE EXTERNAL FUNCTION LOG,EXP
DECLARE FUNCTION SIN,COS
PUBLIC NUMERIC prec
print time$
LET t0=time
LET prec=50 ! ÀºÅÙ
LET M=1850
DIM C(0 TO M),L(M),inv_fac(0 TO prec+1),S(2),Z(2),H(2),W(2),SH(2)
LET C(0)=1
LET S(1)=1/2
LET S(2)=14
250 for K=1 to M
LET L(K)=LOG(K)
for J=K to 1 step -1
LET C(J)=(C(J)+C(J-1))/2 ! C(K)=2^(-K)?
next J
next K
LET inv_fac(0)=1 ! ³¬¾è¤ÎµÕ¿ô
FOR i=1 TO prec+1
LET inv_fac(i)=inv_fac(i-1)/i
NEXT i
300 !' find zeta zero
330 DO ! repeat
350 CALL fnZeta(S,Z)
LET H(1)=(Z(1)*S(1)+Z(2)*S(2))/(S(1)^2+S(2)^2) ! H=Z/S
LET H(2)=(Z(2)*S(1)-Z(1)*S(2))/(S(1)^2+S(2)^2)
MAT SH=S+H
CALL fnZeta(SH,W) ! W=fnZeta(S+H)
LET SH(1)=1-(W(1)*Z(1)+W(2)*Z(2))/(Z(1)^2+Z(2)^2)
LET SH(2)=-(W(2)*Z(1)-W(1)*Z(2))/(Z(1)^2+Z(2)^2)
LET S(1)=S(1)+(H(1)*SH(1)+H(2)*SH(2))/(SH(1)^2+SH(2)^2) ! S+=H/(1-W/Z)
LET S(2)=S(2)+(H(2)*SH(1)-H(1)*SH(2))/(SH(1)^2+SH(2)^2)
360 print using
"-"&REPEAT$("#",7)&"."&REPEAT$("#",20)&"
-"&REPEAT$("#",7)&"."&REPEAT$("#",20):S(1),S(2)
380 LOOP until SQR(Z(1)^2+Z(2)^2)<1/10^18
print int(time-t0);"ÉÃ"
390 !¡¡end
800 !' zeta function
810 SUB fnZeta(X(),U())
820 local J
MAT U=ZER
830 for J=1 to M
LET p1=EXP(X(1)*L(J))*COS(X(2)*L(J))
LET p2=EXP(X(1)*L(J))*SIN(X(2)*L(J))
LET pp=1/(p1^2+p2^2)
LET U(1)=U(1)+(-1)^(J-1)*C(J)*p1*pp ! U+=(-1)^(J-1)*C(J)/J^X
LET U(2)=U(2)-(-1)^(J-1)*C(J)*p2*pp
next J
LET p1=1-EXP((1-X(1))*L(2))*COS(-X(2)*L(2))
LET p2=-EXP((1-X(1))*L(2))*COS(-X(2)*L(2))
LET pp=1/(p1^2+p2^2)
LET u1=(U(1)*p1+U(2)*p2)*pp
LET U(2)=(U(2)*p1-U(1)*p2)*pp ! U/=1-2^(1-X)
LET U(1)=u1
880 END SUB ! return(U)
!
FUNCTION SIN(x)
LET x=MOD(x,2*PI)
LET sum=0
FOR i=0 TO prec/2
LET sum=sum+(-1)^i*x^(2*i+1)*inv_fac(2*i+1)
NEXT i
LET SIN=sum
END FUNCTION
FUNCTION COS(x)
LET x=MOD(x,2*PI)
LET sum=0
FOR i=0 TO prec/2
LET sum=sum+(-1)^i*x^(2*i)*inv_fac(2*i)
NEXT i
LET COS=sum
END FUNCTION
END
!
! 1000·å¥â¡¼¥É¤ÇÍøÍѤ¹¤ëÂпô´Ø¿ô(½½¿ÊBASICźÉÕ"\BASICw32\Library\log.LIB"»²¾È)
EXTERNAL FUNCTION LOG(x)
OPTION ARITHMETIC DECIMAL_HIGH
IF x<=0 THEN
CAUSE EXCEPTION 3004
ELSEIF x<1 THEN
LET log=-log(1/x)
ELSEIF x>3 THEN
LET log=2*log(SQR(x))
ELSE ! 1<=x<=3
LET h=(x-1)/(x+1) ! 0<=h<=0.5
LET t=0
LET n=1
LET k=h
LET h2=H^2
DO
LET t=t+k/n
LET n=n+2
LET k=k*h2
LOOP UNTIL k<=eps(0)*10^(1000-prec) ! ÀºÅÙprec
LET log=2*t
END IF
END FUNCTION
!
! 1000·å¥â¡¼¥É¤ÇÍøÍѤ¹¤ë»Ø¿ô´Ø¿ô(½½¿ÊBASICźÉÕ"\BASICw32\Library\exp.LIB"»²¾È)
EXTERNAL FUNCTION EXP(x)
OPTION ARITHMETIC DECIMAL_HIGH
FUNCTION s(y,n)
LET t=y*x/n
IF ABS(t)<=EPS(0)*10^(1000-prec) THEN ! ÀºÅÙprec
LET s=y+t
ELSE
LET s=y+s(t,n+1)
END IF
END FUNCTION
LET EXP=s(1,1)
END FUNCTION
!¥ê¡¼¥Þ¥ó¤Î¥¼¡¼¥¿´Ø¿ô
!¦Æ(s)=1/(1-2^(1-s))*ô[m=0,¡ç]{2^(-(m+1))*ô[j=0,m]{(-1)^j*comb(m,j)*(j+1)^(-s)}}
LET t0=TIME
LET M=50 !1850
DIM C(0 TO M) !ô2^(-(M+1))*ôcomb(M,J)
LET C(0)=1
FOR K=1 TO M !¥Ñ¥¹¥«¥ë¤Î»°³Ñ·Á¤ÎMÃʤè¤ê¡¢Æó¹à·¸¿ôcomb(m,j)¤òµá¤á¤ë
FOR J=K TO 1 STEP -1
LET C(J)=(C(J)+C(J-1))/2 !¢¨2^(-(m+1))¤â²ÃÌ£¤¹¤ë
NEXT J
NEXT K
FUNCTION fnZeta(S) !¥ê¡¼¥Þ¥ó¤Î¥¼¡¼¥¿´Ø¿ô
local J,U
LET U=0
FOR J=0 TO M
LET U=U+(-1)^J*C(J)/(J+1)^S
NEXT J
LET U=U/(1-2^(1-S))
LET fnZeta=U
END FUNCTION
PRINT C(M) !debug
PRINT fnZeta(2) - PI*PI/6
PRINT "·×»»»þ´Ö=";TIME-t0
END
LET t1$="<H2><A NAME=""CID" ! ID No.
LET t1=LEN(t1$)
LET t2$=""" HREF=""http://6317.teacup.com/basic/bbs/" ! ID No.
LET t2=LEN(t2$)
LET t3$=""" CLASS=""Kiji_Title"">" ! ¥¿¥¤¥È¥ë
LET t3=LEN(t3$)
LET t4$="</A></H2>"
LET t4=LEN(t4$)
!
LET p1$=" Åê¹Æ¼Ô¡§<SPAN CLASS=""Kiji_Author"">" ! Åê¹Æ¼Ô
LET p1=LEN(p1$)
LET p2$="</SPAN>"
LET p2=LEN(p2$)
LET p3$="<A HREF=" ! mailto
LET p3=LEN(p3$)
LET p4$=""">"
LET p4=LEN(p4$)
LET p5$="</A>"
LET p5=LEN(p4$)
!
LET d1$=" Åê¹ÆÆü¡§" ! Åê¹ÆÆü»þ
LET d1=LEN(d1$)
LET d2$="Æü(" ! ÍËÆü
LET d2=LEN(d2$)
!
LET l1$="> <A HREF=""http://6317.teacup.com/basic/bbs/" ! ¸µµ»ö No.
LET l1=LEN(l1$)
LET l2$=">No." ! ¸µµ»ö No.
LET l2=LEN(l2$)
LET l3$="[¸µµ»ö¤Ø]</A><BR><BR>"
LET l3=LEN(l3$)
!
LET finput$="source.txt"
LET foutput$="boardlist.txt"
OPEN #1 : NAME finput$ ,ACCESS INPUT
!
DIM c$(1000)
LET k=0
DO
LINE INPUT #1 , IF MISSING THEN EXIT DO : a$
IF a$(1:l1)=l1$ THEN ! ¸µµ»ö¤¢¤ê
LET ps=POS(a$,l2$,l1+1)
LET ps2=POS(a$,l3$,ps+l2)
LET s$=s$&" "&a$(ps:ps2-1)
ELSEIF a$(1:t1)=t1$ THEN
IF s$<>"" THEN
LET k=k+1
LET c$(k)=s$&"</SMALL>"
END IF
CALL title
END IF
LOOP
IF s$<>"" THEN
LET k=k+1
LET c$(k)=s$&"</SMALL>"
END IF
CLOSE #1
!
OPEN #2 : NAME foutput$ ,ACCESS OUTPUT
SET #2 : POINTER END
FOR i=k TO 1 STEP -1
PRINT #2 : c$(i)
NEXT i
CLOSE #2
!
SUB title
LET s$="<A HREF=""http://6317.teacup.com/basic/bbs/"
LET id$=a$(t1+1:POS(a$,"""",t1+1)-1)
LET s$=id$&" "&s$&id$&"""><B><BIG>"
LET ps=POS(a$,t3$,t1+2)
LET ps2=POS(a$,t4$,ps+t3)
LET
s$=s$&a$(ps+t3:ps2-1)&"</BIG></B></A>
Åê¹Æ¼Ô¡§<FONT COLOR=""#555555""><STRONG>"
LINE INPUT #1 : a$
IF a$(1:p1)=p1$ THEN
IF a$(p1+1:p1+p3)=p3$ THEN
LET
s$=s$&a$(POS(a$,p4$,p1+p3+1)+p4:POS(a$,p5$,p1+p3+3)-1)&"</STRONG></FONT><SMALL>"
ELSE
LET
s$=s$&a$(p1+1:POS(a$,p2$,p1+1)-1)&"</STRONG></FONT><SMALL>"
END IF
END IF
LINE INPUT #1 : a$
LINE INPUT #1 : a$
IF a$(1:d1)=d1$ THEN
LET s$=s$&" "&a$(d1+1:POS(a$,d2$,d1+2))
END IF
END SUB
END
FOR i=10 TO 99 !£²·å¤Î¿ô¤òÇ°¤¸¤ë
LET a=INT(i/10) !½½¤Î°Ì¤È°ì¤Î°Ì¤Î£²¤Ä¤Î¿ô»ú¤ò¤¹
LET b=MOD(i,10) !£²·å¤Î¿ô»ú¤«¤é¤·¤¿Åú¤¨¤ò°ú¤¯
LET s=i-(a+b) !Åú¤¨¡¡s=(10*a+b)-(a+b)=9*a¡¡¡è£¹¤ÎÇÜ¿ô
PRINT i;s !£¹¤ÎÇÜ¿ô¤ÏƱ¤¸¥Þ¡¼¥¯¤Ë¤·¤Æ¡¢¾ï¤Ë¤³¤Î¥Þ¡¼¥¯¤òɽ¼¨¤¹¤ì¤Ð¤è¤¤¡£
!¤¿¤À¡¢Â¿¾¯¤Ï¤º¤ì¤ë¤è¤¦¤Ë°Û¤Ê¤ë¥Þ¡¼¥¯¤âɽ¼¨¤¹¤ë
NEXT i
END
RANDOMIZE
SET bitmap SIZE 501,501
SET WINDOW -0.5,10.5,10,-1
LET z$="c" !£¹¤ÎÇÜ¿ô¤ÏƱ¤¸¥Þ¡¼¥¯
!!!SET TEXT font "MSÌÀÄ«",12
FOR y=0 TO 9 !¿ô»ú
FOR x=0 TO 9
PLOT TEXT ,AT x,y: STR$(10*y+x)
NEXT x
NEXT y
SET TEXT font "Wingdings",18 !¢¨Â礤µ¤ÏÄ´À°¤¬É¬ÍפǤ¢¤ë
FOR y=0 TO 9 !ÀêÀ±½Ñ¤Î¥·¥ó¥Ü¥ë
FOR x=0 TO 9
IF MOD(10*y+x,9)=0 THEN !£¹¤ÎÇÜ¿ô¤Ê¤é
PLOT TEXT ,AT x+0.3,y+0.3: z$
ELSE
PLOT TEXT ,AT x+0.3,y+0.3: CHR$(INT(RND*40)+ORD("T")) !T¡Áz
END IF
NEXT x
NEXT y
INPUT PROMPT "²¿¤«Ê¸»ú¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£":t$ !¥À¥ß¡¼ÆþÎÏ¡ª¡ª¡ª
SET TEXT font "Wingdings",256 !¢¨Â礤µ¤ÏÄ´À°¤¬É¬ÍפǤ¢¤ë
SET TEXT JUSTIFY "center","half"
PLOT TEXT ,AT 5,4.5: z$
END
!Ê£ÁÇ¿ô¤Î·×»»
LET t0=TIME
!¥ê¡¼¥Þ¥ó¤Î¥¼¡¼¥¿´Ø¿ô
!¡¡¦Æ(s)=1/(1-2^(1-s))*ô[m=0,¡ç]{2^(-(m+1))*ô[j=0,m]{(-1)^j*comb(m,j)*(j+1)^(-s)}}
LET M=100 !ÀºÅÙ20·åÄøÅÙ¡¡¡¡¢¨ÀºÅÙ1000·åÄøÅ٤ϡ¢3000
DIM C(0 TO M) !ô2^(-(M+1))*ôcomb(M,J)
LET C(0)=1
FOR K=1 TO M !¥Ñ¥¹¥«¥ë¤Î»°³Ñ·Á¤ÎMÃʤè¤ê¡¢Æó¹à·¸¿ôcomb(m,j)¤òµá¤á¤ë
FOR J=K TO 1 STEP -1
LET C(J)=(C(J)+C(J-1))/2 !¢¨2^(-(m+1))¤â²ÃÌ£¤¹¤ë
NEXT J
NEXT K
PRINT C(M) !debug
SUB fnZeta(ReS,ImS, ReZ,ImZ) !¥ê¡¼¥Þ¥ó¤Î¥¼¡¼¥¿´Ø¿ô
local J
local ReU,ImU,ReT1,ImT1,ReT2,ImT2
LET ReU=0 !LET U=0
LET ImU=0
FOR J=M TO 0 STEP -1
CALL CompPow(J+1,0, ReS,ImS, ReT1,ImT1) !LET U=U+(-1)^J*C(J)/(J+1)^S
CALL CompDiv((-1)^J*C(J),0, ReT1,ImT1, ReT2,ImT2)
CALL CompAdd(ReU,ImU, ReT2,ImT2, ReU,ImU)
NEXT J
CALL CompPow(2,0, 1-ReS,-ImS, ReT1,ImT1) !LET fnZeta=U/(1-2^(1-S))
CALL CompDiv(ReU,ImU, 1-ReT1,ImT1, ReZ,ImZ)
END SUB
!¥¼¡¼¥¿´Ø¿ô¤ÎÎíÅÀ¤Î·×»»¡ÊRiemann zeta zeros¡Ë
LET ReS=1/2 !Èó¼«ÌÀ¤ÊÎíÅÀ¡¡1/2+14*i
LET ImS=14 !1/2+t*i¡¡t=14, 21, 25, 30, 33, 38, 41, 43, 48, 50, ¡Ä ÉÕ¶á
!¥Ë¥å¡¼¥È¥óË¡¤ÇÎíÅÀ¤òµá¤á¤ë
!¡¡sn+1 = sn-¦Æ(sn)/¦Æ'(sn)¡¢¦Æ'(sn)¢â(¦Æ(sn+h)-¦Æ(sn))/h h¤ÏÈù¾®¤ÊÃͤè¤ê
!¡¡sn+1 = sn-¦Æ(sn)*h/(¦Æ(sn+h)-¦Æ(sn)) = sn+h/(1-¦Æ(sn+h)/¦Æ(sn)) ¤È¤Ê¤ë¡£
!¡¡h=¦Æ(sn)/sn ¤È¤·¤Æ¡¢¼ý«¤ÎȽÄê¤Ë¤Ï¦Æ(s)¤ÎÀäÂÐÃͤò»ÈÍѤ¹¤ë¡£
DO
CALL fnZeta(ReS,ImS, ReZ,ImZ) !LET Z=fnZeta(S)
CALL CompDiv(ReZ,ImZ,ReS,ImS, ReH,ImH) !LET H=Z/S
CALL fnZeta(ReS+ReH,ImS+ImH, ReW,ImW) !LET W=fnZeta(S+H)
CALL CompDiv(ReW,ImW, ReZ,ImZ, ReT1,ImT1) !LET S=S+H/(1-W/Z)
CALL CompDiv(ReH,ImH, 1-ReT1,-ImT1, ReT2,ImT2)
CALL CompAdd(ReS,ImS, ReT2,ImT2, ReS,ImS)
PRINT USING "####.#################### ####.####################": ReS,ImS !PRINT S
LOOP UNTIL CompABS(ReZ,ImZ)<1/10^18 !LOOP UNTIL ABS(Z)<1/10^18
!¼ý«¤¹¤ë¤Þ¤Ç¡¡¢¨ÀºÅÙ¤ÏÄ´À°¤¬É¬ÍפǤ¢¤ë¡£10¿Ê¥â¡¼¥É¡¢2¿Ê¥â¡¼¥É¤Ç¤Ï1/10^8ÄøÅÙ
PRINT "·×»»»þ´Ö=";TIME-t0
END
!Ê£ÁÇ¿ô¤Î·×»»
EXTERNAL FUNCTION CompRe(x,y) !¼ÂÉô (x+y*i)¡¢x,y¤Ï¼Â¿ô¡¢i¤Ïµõ¿ôñ°Ì
LET CompRe=x
END FUNCTION
EXTERNAL FUNCTION CompIm(x,y) !µõÉô Im(x+y*i)
LET CompIm=y
END FUNCTION
EXTERNAL SUB CompConj(x1,y1, x,y) !¶¦ÌòÊ£ÁÇ¿ô
LET xx=x1
LET yy=-y1
LET x=xx
LET y=yy
END SUB
EXTERNAL FUNCTION CompABS(x,y) !ÀäÂÐÃÍ |x+y*i|
!a'=MAX(ABS(a),ABS(b))¡¢b'=MIN(ABS(a),ABS(b))¤È¤·¤Æ¡¢SQR(a*a+b*b)=a'*SQR(1+(b'/a')^2)¤òµá¤á¤ë¡£
IF x=0 THEN
LET r=ABS(y)
ELSEIF y=0 THEN
LET r=ABS(x)
ELSEIF ABS(y)>ABS(x) THEN
LET t=x/y
LET r=ABS(y)*SQR(1+t*t)
ELSE
LET t=y/x
LET r=ABS(x)*SQR(1+t*t)
END IF
LET CompABS=r
END FUNCTION
EXTERNAL FUNCTION CompARG(x,y) !ÊÐ³Ñ¦È (-¦Ð,¦Ð]
IF x>0 THEN !Â裱¾Ý¸Â¡¢Â裴¾Ý¸Â
LET r=ATN2(y/x)
ELSE
IF x<0 THEN
IF y>=0 THEN !Â裲¾Ý¸Â
LET r=ATN2(y/x)+PI
ELSE !Â裳¾Ý¸Â
LET r=ATN2(y/x)-PI
END IF
ELSE !x=0
IF y>0 THEN !¡ç
LET r=PI/2
ELSE
IF y<0 THEN !-¡ç
LET r=-PI/2
ELSE !y=0
PRINT "ARG´Ø¿ô¤ÏÉÔÄê¤Ç¤¹¡£"
STOP
END IF
END IF
END IF
END IF
LET CompARG=r
END FUNCTION
!±é»»´ØÏ¢¡¡¤Ù¤¾è
EXTERNAL SUB CompPow(x1,y1, x2,y2, x,y) !¤Ù¤¾è (x1+y1*i) ^ (x2+y2*i) ¢ª x+y*i
CALL CompLOG(x1,y1, s,t) !z1^z2=exp(log(z1)*z2)¤è¤ê
CALL CompMul(s,t, x2,y2, a,b)
CALL CompEXP(a,b, x,y)
END SUB
!±é»»´ØÏ¢¡¡»Í§±é»»¡¢´Ø¿ô¤Ê¤É
EXTERNAL SUB CompAdd(x1,y1, x2,y2, x,y) !²Ã»» (x1+y1*i) + (x2+y2*i) ¢ª x+y*i
LET xx=x1+x2 !¼ÂÉô
LET yy=y1+y2 !µõÉô
LET x=xx
LET y=yy
END SUB
EXTERNAL SUB CompSub(x1,y1, x2,y2, x,y) !¸º»» (x1+y1*i) - (x2+y2*i) ¢ª x+y*i
LET xx=x1-x2
LET yy=y1-y2
LET x=xx
LET y=yy
END SUB
EXTERNAL SUB CompMul(x1,y1, x2,y2, x,y) !¾è»» (x1+y1*i) * (x2+y2*i) ¢ª x+y*i
LET xx=x1*x2-y1*y2 !´Ý¤á¸íº¹Âкö
LET yy=x1*y2+y1*x2
LET x=xx
LET y=yy
END SUB
EXTERNAL SUB CompDiv(x1,y1, x2,y2, x,y) !½ü»» (x1+y1*i) / (x2+y2*i) ¢ª x+y*i
IF x2=0 AND y2=0 THEN
PRINT "£°¤Ç¤Ï³ä¤ì¤Þ¤»¤ó¡£"
STOP
END IF
IF ABS(x2)>=ABS(y2) THEN !¾å°Ì·å¤¢¤Õ¤ìÂкö
LET w=y2/x2
LET tt=x2+y2*w
LET xx=(x1+y1*w)/tt
LET yy=(y1-x1*w)/tt
ELSE
LET w=x2/y2
LET tt=x2*w+y2
LET xx=(x1*w+y1)/tt
LET yy=(y1*w-x1)/tt
END IF
LET x=xx
LET y=yy
END SUB
EXTERNAL SUB CompSQR(x1,y1, x,y) !Ê¿Êýº¬
LET SQRT05=SQR(1/2) !0.707106781186547524
LET r=CompABS(x1,y1) !r=SQR(x1*x1+y1*y1)
LET w=SQR(r+ABS(x1))
IF x1>=0 THEN
LET x=SQRT05*w
LET y=SQRT05*y1/w
ELSE
LET x=SQRT05*ABS(y1)/w
IF y1>=0 THEN LET y=SQRT05*w ELSE LET y=-SQRT05*w
END IF
END SUB
EXTERNAL SUB CompEXP(x1,y1, x,y) !»Ø¿ô´Ø¿ô
DECLARE EXTERNAL FUNCTION EXP,SIN,COS !´Ø¿ô¤Î¥ª¡¼¥Ð¡¼¥í¡¼¥É
LET t=EXP(x1) !EXP(x+i*y)=EXP(x)*EXP(i*y)=EXP(x)*(COS(y)+i*SIN(y))
LET xx=t*COS(y1)
LET yy=t*SIN(y1)
LET x=xx
LET y=yy
END SUB
EXTERNAL SUB CompLOG(x1,y1, x,y) !Âпô´Ø¿ô
DECLARE EXTERNAL FUNCTION LOG !´Ø¿ô¤Î¥ª¡¼¥Ð¡¼¥í¡¼¥É
LET xx=0.5*LOG(x1*x1+y1*y1) !LOG(r)+i*¦È¡¢-¦Ð<¦È<=¦Ð
LET yy=CompARG(x1,y1)
LET x=xx
LET y=yy
END SUB
!Êä½õ¥ë¡¼¥Á¥ó¡¡¢¨Â¿·å¤Î´Ø¿ô
EXTERNAL FUNCTION ATN2(x) !¥¢¡¼¥¯¥¿¥ó¥¸¥§¥ó¥È (-¦Ð/2,¦Ð/2)
IF x>1 THEN
LET cSGN=1
LET x=1/x
ELSEIF x<-1 THEN
LET cSGN=-1
LET x=1/x
ELSE
LET cSGN=0
END IF
LET a=0
FOR i=1500 TO 1 STEP -1 !¢¨·«¤êÊÖ¤·²ó¿ô¤ÏÄ´À°¤¬É¬ÍפǤ¢¤ë
LET a0=a
LET a=(i*i*x*x)/(2*i+1 + a)
IF ABS(a-a0)<=EPS(0) THEN EXIT FOR
NEXT i
IF cSGN>0 THEN
LET ATN2=PI/2-x/(1+a)
ELSEIF cSGN<0 THEN
LET ATN2=-PI/2-x/(1+a)
ELSE
LET ATN2=x/(1+a)
END IF
END FUNCTION
MERGE "EXP.LIB" !»Ø¿ô´Ø¿ô¡¡¢¨µé¿ôŸ³«¤Ç´Ø¿ô¤ò·×»»¤¹¤ë
MERGE "LOG.LIB" !Âпô´Ø¿ô
MERGE "TRIGONOM.LIB" !»°³Ñ´Ø¿ô¡ÊÀµ¸¹¡¤Í¾¸¹¡¤ÀµÀÜ¡Ë
!±é»»´ØÏ¢¡¡¤Ù¤¾è¡¢´Ø¿ô¤Ê¤É
EXTERNAL SUB CompPowN(x1,y1, n, x,y) !¤Ù¤¾è (x1+y1*i) ^ n ¢ª x+y*i
DECLARE EXTERNAL FUNCTION SIN,COS !´Ø¿ô¤Î¥ª¡¼¥Ð¡¼¥í¡¼¥É
LET r=CompABS(x1,y1) !r,¦È
LET th=CompARG(x1,y1)
LET t=r^n !z^n=r^n*(COS(n*¦È)+i*SIN(n*¦È))¡¢r=SQR(x1*x1+y1*y1)
LET x=t*COS(n*th)
LET y=t*SIN(n*th)
END SUB
EXTERNAL SUB CompNPow(n, x1,y1, x,y) !¤Ù¤¾è n ^ (x1+y1*i) ¢ª x+y*i
DECLARE EXTERNAL FUNCTION LOG !´Ø¿ô¤Î¥ª¡¼¥Ð¡¼¥í¡¼¥É
CALL CompMul(LOG(n),0, x1,y1, a,b) !n^z1=exp(log(n)*z1)¤è¤ê
CALL CompEXP(a,b, x,y)
END SUB
EXTERNAL SUB CompSIN(x1,y1, x,y) !»°³Ñ´Ø¿ô¡¡Àµ¸¹
DECLARE EXTERNAL FUNCTION EXP,SIN,COS !´Ø¿ô¤Î¥ª¡¼¥Ð¡¼¥í¡¼¥É
!sin(x+yi)
!={exp(x*i-y)-exp(-x*i+y)}/(2*i)¡¡ ¢¨sin(z)=(exp(i*z)-exp(-i*z))/(2*i)¤è¤ê
!={exp(-y)*(cos(x)+i*sin(x))-exp(y)*(cos(x)-i*sin(x))}/(2*i)¡¡¢¨exp(i*x)=cos(x)+i*sin(x)¤è¤ê
!={(exp(y)-exp(-y))*(-cos(x)) + (exp(y)+exp(-y))*sin(x)*i}/(2*i)
!={(exp(y)-exp(-y))*cos(x)*i + (exp(y)+exp(-y))*sin(x)}/2
LET e=EXP(y1)
LET f=1/e
LET yy=0.5*(e-f)*COS(x1)
LET xx=0.5*(e+f)*SIN(x1)
LET x=xx
LET y=yy
END SUB
EXTERNAL SUB CompCOS(x1,y1, x,y) !»°³Ñ´Ø¿ô¡¡Í¾¸¹
DECLARE EXTERNAL FUNCTION EXP,SIN,COS !´Ø¿ô¤Î¥ª¡¼¥Ð¡¼¥í¡¼¥É
LET e=EXP(y1) !(exp(i*z)+exp(-i*z))/2
LET f=1/e
LET yy=0.5*(f-e)*SIN(x1)
LET xx=0.5*(f+e)*COS(x1)
LET x=xx
LET y=yy
END SUB
EXTERNAL SUB CompTAN(x1,y1, x,y) !»°³Ñ´Ø¿ô¡¡ÀµÀÜ
DECLARE EXTERNAL FUNCTION EXP,SIN,COS !´Ø¿ô¤Î¥ª¡¼¥Ð¡¼¥í¡¼¥É
LET e=EXP(2*y1)
LET f=1/e
LET d=COS(2*x1)+0.5*(e+f)
LET x=SIN(2*x1)/d
LET y=(e-f)/d
END SUB
!µÕ»°³Ñ´Ø¿ô
!¡¡ArcSin(z)=-i*LOG(SQR(1-z^2)+z*i)
!¡¡ArcCos(z)=-i*LOG(z+i*SQR(1-z^2))
!¡¡ArcTan(z)=i/2*LOG((i+z)/(i-z))
EXTERNAL SUB CompSinh(x1,y1, x,y) !ÁжÊÀþÀµ¸¹
DECLARE EXTERNAL FUNCTION EXP,SIN,COS !´Ø¿ô¤Î¥ª¡¼¥Ð¡¼¥í¡¼¥É
LET e=EXP(x1)
LET f=1/e
LET xx=0.5*(e-f)*COS(y1)
LET yy=0.5*(e+f)*SIN(y1)
LET x=xx
LET y=yy
END SUB
EXTERNAL SUB CompCosh(x1,y1, x,y) !ÁжÊÀþ;¸¹
DECLARE EXTERNAL FUNCTION EXP,SIN,COS !´Ø¿ô¤Î¥ª¡¼¥Ð¡¼¥í¡¼¥É
LET e=EXP(x1)
LET f=1/e
LET xx=0.5*(e+f)*COS(y1)
LET yy=0.5*(e-f)*SIN(y1)
LET x=xx
LET y=yy
END SUB
EXTERNAL SUB ComppTanh(x1,y1, x,y) !ÁжÊÀþÀµÀÜ
DECLARE EXTERNAL FUNCTION EXP,SIN,COS !´Ø¿ô¤Î¥ª¡¼¥Ð¡¼¥í¡¼¥É
LET e=EXP(2*x1)
LET f=1/e
LET d=0.5*(e+f)+COS(2*y1)
LET y=SIN(2*y1)/d
LET x=0.5*(e-f)/d
END SUB
!x^2*(d2y/dx2)+x*(dy/dx)+(x^2-a^2)*y=0 ¡Ä¥Ù¥Ã¥»¥ë
!x^2*(d2y/dx2)+x*(dy/dx)-(x^2+a^2)*y=0 ¡ÄÊÑ·Á¥Ù¥Ã¥»¥ë
!-------------------------------
OPTION ARITHMETIC NATIVE
OPTION BASE 0
SET TEXT background "opaque"
DIM col(4), y0(4)
MAT READ col
DATA 4,10,2,14, 12 ! £°¼¡ ¡Á£´¼¡¤Î¿§Ê¬¤±
!-----------------------------------------------------------------------
!0Çò 1¹õ
2ÀÄ 3
ÎÐ 4ÀÖ 5¿å
¿§ 6²«
¿§ 7ÀÖ»ç
! 8³¥¿§ 9Ç»¤¤ÀÄ 10Ç»¤¤ÎÐ 11ÀÄÎÐ 12¤¨¤ÓÃã 13¥ª¥ê¡¼¥Ö¿§ 14Ç»¤¤»ç 15¶ä¿§
!-----------------------------------------------------------------------
SUB Dji( oddy,ody, iddy,idy,y)
LET oddy=-( x*idy +(sj*x^2-a^2)*y)/x^2 ! ddy=(d2y/dx2) :sj=1(¥Ù¥Ã¥»¥ë)
LET ody=-(x^2*iddy+(sj*x^2-a^2)*y)/x ! dy= (dy/dx) :sj=-1(ÊÑ·Á¥Ù¥Ã¥»¥ë)
END SUB
SUB RungeKutta
CALL Dji( oddy1,ody1, iddy, idy, y)
CALL Dji( oddy2,ody2, iddy, idy+oddy1*dx/2, y+ody1*dx/2)
CALL Dji( oddy3,ody3, iddy, idy+oddy2*dx/2, y+ody2*dx/2)
CALL Dji( oddy4,ody4, iddy, idy+oddy3*dx , y+ody3*dx )
LET y=y+(ody1+2*ody2+2*ody3+ody4)*dx/6
LET idy=idy+(oddy1+2*oddy2+2*oddy3+oddy4)*dx/6
LET iddy=oddy4
END SUB
LET dx=.0005 !pitch
LET y0(0)=1 !£ù¤Î½é´üÃÍ
LET y0(1)= 0.708248*dx
LET y0(2)=-1.2017 *dx^2
LET y0(3)=-0.015 *dx^3
LET y0(4)= 0.00615 *dx^4
!-----
LET sj=-1
LET m$="ÊÑ·Á"
CALL window_
CALL Rk_bessel !ÊÑ·Á¥Ù¥Ã¥»¥ë¤ÎÈùʬÊýÄø¼°( ¥ë¥ó¥²¥¯¥Ã¥¿ÉÁ²è )
CALL fn_bessel !ÊÑ·Á¥Ù¥Ã¥»¥ë´Ø¿ô£±¼ï In(x)
WAIT DELAY 2
!-----
LET sj=1
LET m$=""
CALL window_
CALL Rk_bessel ! ¥Ù¥Ã¥»¥ë¤ÎÈùʬÊýÄø¼°( ¥ë¥ó¥²¥¯¥Ã¥¿ÉÁ²è )
CALL fn_bessel ! ¥Ù¥Ã¥»¥ë´Ø¿ô£±¼ï Jn(x)
SUB window_
CLEAR
IF sj=1 THEN !----¥Ù¥Ã¥»¥ë
LET h=1
LET l=-1
LET xr=20
SET WINDOW -3,xr, l, h
DRAW grid(xr/4,h/5)
ELSEIF sj=-1 THEN !----ÊÑ·Á¥Ù¥Ã¥»¥ë
LET h=4
LET l=-1.5
LET xr=4
SET WINDOW -0.3,xr, l, h
DRAW grid(xr/8,h/8)
END IF
ASK PIXEL SIZE(0,0;xr,0) px,py
LET ss=Xr/px
END SUB
!-------------------- ÈùʬÊýÄø¼°¤Î¥ë¥ó¥²¥¯¥Ã¥¿ÉÁ²è
SUB Rk_bessel
SET TEXT COLOR 4
PLOT TEXT,AT (.325+.225*sj)*xr,.9*h-(.2-.04*sj)*(h-l) :"¥ë¥ó¥²¥¯¥Ã¥¿ÉÁ²è"
FOR a=0 TO 4
LET y=y0(a)
LET idy=0
LET iddy=0
SET LINE COLOR "gray" !col(a+4)
SET TEXT COLOR "gray" !col(a+4)
PLOT TEXT,AT .1*xr,.9*h-.04*(h-l)*a :m$& "¥Ù¥Ã¥»¥ë¤ÎÈùʬÊýÄø¼° "& STR$(a)& "¼¡"
!------------
FOR x=dx TO xr+dx STEP dx
PLOT LINES: x,y; ! PEN-on
IF FP(x)< dx THEN PRINT USING"##.## ###.######":x,y
CALL RungeKutta
NEXT x
!------------
PLOT LINES !PEN-off
PRINT
NEXT a
END SUB
!********************* ²ò¤Î¥Ù¥Ã¥»¥ë´Ø¿ô¤ò½Å¤Í¤Æ¾È¹ç¤¹¤ë¡£
SUB fn_bessel
SET TEXT COLOR 1
PLOT TEXT,AT (.325+.225*sj)*xr,.9*h-(.2-.04*sj)*(h-l) :"´Ø¿ô¤Ç¡¢½Å¤Í½ñ¤"
FOR n=0 TO 4
SET LINE COLOR col(n)
SET TEXT COLOR col(n)
PLOT TEXT,AT .1*xr,.9*h-.04*(h-l)*n :m$& "¥Ù¥Ã¥»¥ë´Ø¿ô£±¼ï "& STR$(n)& "¼¡¡¡¡¡"
!------------²èÁÇ´Ö³Ö¤ÎStep
FOR x=dx TO xr+ss STEP ss
PLOT LINES: x,bessel(n,x); ! PEN-on
IF FP(x)< ss AND
dx< x THEN PRINT USING"##.## ###.######":IP(x),bessel(n,IP(x))
NEXT x
!------------
PLOT LINES !PEN-off
PRINT
NEXT n
END SUB
!------- ¥Ù¥Ã¥»¥ë´Ø¿ô¡¡ÊÑ·Á¥Ù¥Ã¥»¥ë´Ø¿ô
FUNCTION bessel(n,x)
LET m=2*INT( (6+MAX(n,1.5*ABS(x))+9*1.5*ABS(x)/(1.5*ABS(x)+2))/2)
LET w=0
IF sj=1 THEN !---- ¥Ù¥Ã¥»¥ë´Ø¿ô Jn(x)
FOR k=1 TO m/2
LET w=w+Tk(k*2,x)
NEXT k
LET bessel=Tk(n,x)/(Tk(0,x)+2*w)
ELSEIF sj=-1 THEN !---- ÊÑ·Á¥Ù¥Ã¥»¥ë´Ø¿ô In(x)
FOR k=1 TO m
LET w=w+Tk(k,x)
NEXT k
LET bessel=EXP(x)*Tk(n,x)/(Tk(0,x)+2*w)
END IF
END FUNCTION
FUNCTION Tk(i,x)
LET t2=0
LET t1=1e-9
LET t0=2*(m+1)/x*t1-sj*t2
FOR kp1=m TO i+1 STEP -1
LET t2=t1
LET t1=t0
LET t0=2*kp1/x*t1-sj*t2
NEXT kp1
LET Tk=t0
END FUNCTION
!Ⱦ̵¸Â¶è´ÖÀÑʬ¡¡¢é[0,¡ç]{EXP(-x)*f(x)}dx
DEF F(X)=1/(1-EXP(-X)) - 1/X
LET S=0
FOR I=1 TO 20
READ X,W
LET S=S+W*F(X)
NEXT I
PRINT S
DATA .0705398896919888, 1.6874680185111386E-01 !¥¬¥¦¥¹¡¦¥é¥²¡¼¥ë§¤Î·¸¿ô¡ÊʬÅÀ¡¢½Å¤ß¡Ë
DATA .3721268180016114, 2.9125436200606828E-01 !£²£°¼¡¥é¥²¡¼¥ë¿¹à¼°¤è¤ê
DATA .9165821024832736, 2.6668610286700129E-01
DATA 1.7073065310283439, 1.6600245326950684E-01
DATA 2.7491992553094321, 7.4826064668792371E-02
DATA 4.0489253138508869, 2.4964417309283221E-02
DATA 5.6151749708616165, 6.2025508445722368E-03
DATA 7.4590174536710633, 1.1449623864769082E-03
DATA 9.5943928695810968, 1.5574177302781197E-04
DATA 12.0388025469643163, 1.5401440865224916E-05
DATA 14.8142934426307400, 1.0864863665179824E-06
DATA 17.9488955205193760, 5.3301209095567148E-08
DATA 21.4787882402850110, 1.7579811790505820E-09
DATA 25.4517027931869055, 3.7255024025123209E-11
DATA 29.9325546317006120, 4.7675292515781905E-13
DATA 35.0134342404790000, 3.3728442433624384E-15
DATA 40.8330570567285711, 1.1550143395003988E-17
DATA 47.6199940473465021, 1.5395221405823436E-20
DATA 55.8107957500638989, 5.2864427255691578E-24
DATA 66.5244165256157538, 1.6564566124990233E-28
END
OPTION ARITHMETIC NATIVE
!£²½Å»Ø¿ô´Ø¿ô·¿¿ôÃÍÀÑʬ¡ÊDouble Exponential formula¡Ë
!¡¡¢é[0,¡ç]f(x)dx¡¡È¾Ìµ¸ÂÎΰè(0,¡ç)¤ÎÀÑʬ
!
!¡¡x=EXP(t-EXP(-t))¤È¤¹¤ë¤È¡¢dx/dt=EXP(t-EXP(-t))*(1+EXP(-t))
!¡¡Í¿¼°=¢é[-¡ç,¡ç]{f(EXP(t-EXP(-t)))*EXP(t-EXP(-t))*(1+EXP(-t))}dt
DEF f(x)=EXP(-x)/(1-EXP(-x)) - EXP(-x)/x !¢é[0,¡ç]f(x)dx = 0.5772156649015328606¡Ä¡¡¥ª¥¤¥é¡¼¤ÎÄê¿ô¦Ã
LET N=36 !ʬ³ä¿ô
LET h=1/6
LET s=0
FOR j=-N/2 TO N/2
LET t=j*h
LET v=EXP(-t)
LET x=EXP(t-v)
LET s=s + f(x)*x*(1+v)
NEXT j
LET s=h*s
PRINT s !·ë²Ì¤òɽ¼¨¤¹¤ë
!£²½Å»Ø¿ô´Ø¿ô·¿¿ôÃÍÀÑʬ¡ÊDouble Exponential formula¡Ë
!¡¡¢é[0,¡ç]f(x)dx¡¡È¾Ìµ¸ÂÎΰè(0,¡ç)¤ÎÀÑʬ
!
!¡¡x=EXP(PI*SINH(t))¤È¤¹¤ë¤È¡¢dx/dt=EXP(PI*SINH(t))*PI*COSH(t)
!¡¡Í¿¼°=PI*¢é[-¡ç,¡ç]{f(EXP(PI*SINH(t)))*EXP(PI*SINH(t))*COSH(t)}dt
DEF g(x)=1/(1+x^6) !¢é[0,¡ç]g(x)dx = PI/3
LET N=64 !ʬ³ä¿ô
LET h=1/8
LET s=0
FOR j=-N/2 TO N/2
LET t=j*h
LET x=EXP(PI*SINH(t))
LET s=s + g(x)*x*COSH(t)
NEXT j
LET s=h*PI*s
PRINT s !·ë²Ì¤òɽ¼¨¤¹¤ë
PRINT PI/3 !¸¡»»
!£²½Å»Ø¿ô´Ø¿ô·¿¿ôÃÍÀÑʬ¡ÊDouble Exponential formula¡Ë
!¡¡¢é[-1,1]f(x)dx
!
!¡¡x=TANH(PI/2*SINH(t))¤È¤¹¤ë¤È¡¢dx/dt=PI/2*COSH(t)/COSH(PI/2*SINH(t))^2
!¡¡Í¿¼°=PI/2*¢é[-¡ç,¡ç]{f(TANH(PI/2*SINH(t)))*COSH(t)/COSH(PI/2*SINH(t))^2}dt
DEF f2(x)=SQR(1-x^2)/(2-x) !¢é[-1,1]f(x)dx = PI*(2-SQR(3))
LET N=64 !ʬ³ä¿ô
LET h=1/8
LET s=0
FOR j=-N/2 TO N/2
LET t=j*h
LET v=PI/2*SINH(t)
LET s=s + f2(TANH(v))*COSH(t)/COSH(v)^2
NEXT j
LET s=h*PI/2*s
PRINT s !·ë²Ì¤òɽ¼¨¤¹¤ë
PRINT PI*(2-SQR(3)) !¸¡»»
END
PICTURE Building(x,y,w,h,d1)
IF d-i<=w THEN
!---back plane
LET zY(1,1)=d_yaw(i+w/2) !£Ú¼´¥«¡¼¥Ö¤ÎÈùʬ dx/dz
LET
zY(4,1)=x+d1
!ZYÊ¿Ì̤ΣøºÂɸ
DRAW Wall((y),w,h) WITH zY
!---facade
LET
zY(4,1)=x !ZYÊ¿Ì̤ΣøºÂɸ
DRAW Wall((y),w,h) WITH zY
!---side plane
LET XYz(4,1)=d_yaw(i+w/2)*w !£Ú¼´¥«¡¼¥Ö¤Ë¤è¤ë£ø°ÜÆ°º¹Ê¬
LET
XYz(4,3)=w
!£Ú¼´ °ÜÆ°º¹Ê¬
DRAW Side(x,y,h,d1) WITH XYz
END IF
END PICTURE
!
PICTURE Wall(y,w,h)
SET AREA COLOR 8 !gray
PLOT AREA: 0,y; w,y; w,y+h; 0,y+h !(Z,Y)Ê¿Ì̤Ȥ·¤ÆÉÁ¤¯¡£
FOR y=y+h-.5 TO y+1 STEP -2.5
PLOT LINES: 0,y;
w,y !
(Z,Y)Ê¿Ì̤Ȥ·¤ÆÉÁ¤¯¡£
NEXT y
END PICTURE
!
PICTURE Side(x,y,h,d1)
SET AREA COLOR 16 !dark gray
PLOT AREA: x,y; x+d1,y; x+d1,y+h; x,y+h !°ÜÆ°Á°(X,Y)Ê¿Ì̤Ȥ·¤ÆÉÁ¤¯¡£
END PICTURE
PICTURE Road(e)
IF e< d-i THEN LET e=d-i
LET Xz(2,1)=d_yaw(i+e/2) !£Ú¼´¥«¡¼¥Ö¤ÎÈùʬ dx/dz
LET Xz(2,2)=d_pitch(i+e/2) !£Ú¼´¥Ô¥Ã¥Á¤ÎÈùʬ dy/dz
DRAW Surface(e) WITH Xz
END PICTURE
!
PICTURE Surface(e)
SET AREA COLOR 15
PLOT AREA: 0,0; 6,0; 6,e; 0,e !(X,Z)Ê¿Ì̤Ȥ·¤ÆÉÁ¤¯¡£
!---center line
SET AREA COLOR 0
PLOT AREA: 2.9,0; 2.9,e; 3.1,e; 3.1,0 !(X,Z)Ê¿Ì̤Ȥ·¤ÆÉÁ¤¯¡£
!---joint line
PLOT LINES: 0 ,0; 2.9,0
PLOT LINES: 3.1,0; 6 ,0
END PICTURE
PICTURE Tree
SET AREA COLOR 12 !´´
PLOT AREA:-0.075,0; 0.075,0; 0.025,3;-0.025,3
SET AREA COLOR 10
FOR w=1 TO 7 !ÍÕ
DRAW disk WITH SCALE(0.3+0.05-RND*0.1)*SHIFT(0.4-RND*0.8, 2.7+0.325-RND*0.75)
NEXT W
END PICTURE
PICTURE Sign
IF MOD(i,50)=0 THEN SET AREA COLOR 2 ELSE SET AREA COLOR 4
PLOT AREA:-0.025,0; 0.025,0; 0.025,2;-0.025,2 !pole
DRAW disk WITH SCALE(0.5)*SHIFT(0,2) !plate
!PLOT TEXT,AT -.35,1.74,USING ">%%":STR$(i) !sign
CALL Plot_7segment(0 ,2 ,0.15 ,STR$(i)) !sign( PLOT TEXT ¤¬½Å¤¤»þ)
END PICTURE
SUB Plot_7segment(x,y,s,i$) !ʸ»úÎóÃæ¿´(x,y) ʸ»ú¤Î²£Éý(s) ¿ô»ú¤Îʸ»úÎó(i$)
SET LINE COLOR 0
SET LINE width 9/(i-d+1.5) !°ìÅÀÅê±Æ¡¦½Ì¾®¤ÎÊä½þ¡£(ÀþÉý¤Ï MAT ʸ¤Ç½Ì¤Þ¤Ê¤¤)
LET w=LEN(i$)
LET s1=s ! y¼´¢¬:s1=s y¼´¢:s1=-s
LET s2=s/2
LET x=x-(w-1)*s2*1.6
FOR p=1 TO w
SELECT CASE VAL(i$(p:p))
CASE 0
PLOT LINES:x-s2,y+s;x-s2,y-s;x+s2,y-s;x+s2,y+s;x-s2,y+s
CASE 1
PLOT LINES:x,y-s;x,y+s
CASE 2
PLOT LINES:x-s2,y+s1;x+s2,y+s1;x+s2,y;x-s2,y;x-s2,y-s1;x+s2,y-s1
CASE 3
PLOT LINES:x-s2,y-s;x+s2,y-s;x+s2,y+s;x-s2,y+s
PLOT LINES:x-s2,y;x+s2,y
CASE 4
PLOT LINES:x-s2,y+s1;x-s2,y;x+s2,y
PLOT LINES:x+s2,y+s1;x+s2,y-s1
CASE 5
PLOT LINES:x+s2,y+s1;x-s2,y+s1;x-s2,y;x+s2,y;x+s2,y-s1;x-s2,y-s1
CASE 6
PLOT LINES:x+s2,y+s1;x-s2,y+s1;x-s2,y-s1;x+s2,y-s1;x+s2,y;x-s2,y
CASE 7
PLOT LINES:x-s2,y+s1;x+s2,y+s1;x+s2,y-s1
CASE 8
PLOT LINES:x-s2,y;x-s2,y-s;x+s2,y-s;x+s2,y+s;x-s2,y+s;x-s2,y;x+s2,y
CASE 9
PLOT LINES:x+s2,y;x-s2,y;x-s2,y+s1;x+s2,y+s1;x+s2,y-s1;x-s2,y-s1
CASE ELSE
END SELECT
LET x=x+s*1.6
NEXT p
SET LINE width 1
SET LINE COLOR 1
END SUB
!¥¤¥ó¥Ù¡¼¥À¡¼¡¦¥²¡¼¥à
DEF V2W(x)=4*x !²¾ÁÛ²èÌ̤κÂɸ¤òʪÍý²èÌ̤κÂɸ¤Ø
DEF W2V(x)=INT(x/4) !¤½¤ÎµÕ
PICTURE DOT !ʪÍý²èÌ̤˥ɥåȤòɽ¼¨¤¹¤ë
PLOT AREA: -2,-2; 2,-2; 2,2; -2,2 !4x4
END PICTURE
LET vx=180 !²¾ÁÛ²èÌ̤ÎÂ礤µ¡¡150¡ß180¥É¥Ã¥È
LET vy=150
SET bitmap SIZE V2W(vx)+1,V2W(vy)+1 !ʪÍý²èÌ̤ÎÂ礤µ
SET WINDOW 0,V2W(vx),V2W(vy),0 !¥¹¥¯¥ê¡¼¥óºÂɸ
RANDOMIZE
!------------------------------ ÃÆ
DATA "* " !¥³¥Þ£±¡¡ÃÆ£±
DATA " *"
DATA "* "
DATA " *" !¥³¥Þ£²
DATA "* "
DATA " *"
DIM bm$(1,2) !ÃÆ¡¡3¡ß2¥É¥Ã¥È
CALL ReadPattern(1,3, bm$)
LET NumOfBeam=5 !ÃÆ¡¡ºÇÂç¿ô£µ
DIM BM(NumOfBeam,3)
MAT BM=(-1)*CON
!------------------------------ ¥¤¥ó¥Ù¡¼¥À¡¼
LET m=8 !m¡ßn¥É¥Ã¥È
LET n=11
DATA "** **" !¥³¥Þ£±¡¡µ¡ÂΣ°
DATA "* *"
DATA " "
DATA " "
DATA " "
DATA " "
DATA "* *"
DATA "** **"
DATA " " !¥³¥Þ£²
DATA "* * * *"
DATA " * * * * "
DATA " * * "
DATA "** **"
DATA " * * "
DATA " * * * * "
DATA "* * * *"
DATA " * * " !¥³¥Þ£±¡¡µ¡ÂΣ±
DATA "* * * *"
DATA "* ******* *"
DATA "*** *** ***"
DATA "***********"
DATA " ********* "
DATA " * * "
DATA " * * "
DATA " * * " !¥³¥Þ£²
DATA " * * "
DATA " ******* "
DATA " ** *** ** "
DATA "***********"
DATA "* ******* *"
DATA "* * * *"
DATA " ** ** "
DATA " *** " !¥³¥Þ£±¡¡µ¡ÂΣ²
DATA " ***** "
DATA " ******* "
DATA " ** *** ** "
DATA " ********* "
DATA " * * "
DATA " * * * * "
DATA " * * * * "
DATA " *** " !¥³¥Þ£²
DATA " ***** "
DATA " ******* "
DATA " ** *** ** "
DATA " ********* "
DATA " * *** * "
DATA " * * "
DATA " * * "
DATA " " !¥³¥Þ£±¡¡µ¡ÂΣ³
DATA " *** "
DATA " ********* "
DATA "** *** **"
DATA "***********"
DATA " ***** "
DATA " ** * ** "
DATA "** **"
DATA " " !¥³¥Þ£²
DATA " *** "
DATA " ********* "
DATA "** *** **"
DATA "***********"
DATA " ** ** "
DATA " * * "
DATA " * * "
DIM ptn$(4,2) !¥Ñ¥¿¡¼¥ó¡Ê£±µ¡¡ß£²¥³¥Þ¡Ë¤ÇÆɤ߹þ¤à
CALL ReadPattern(4,m, ptn$)
SUB ReadPattern(n,l, ptn$(,))
FOR k=1 TO n !³Æµ¡ÂÎ
FOR j=1 TO 2 !³Æ¥³¥Þ
LET v$=""
FOR i=1 TO l
READ s$
LET v$=v$&s$
NEXT i
LET ptn$(k,j)=v$ !ÅÐÏ¿¤¹¤ë
NEXT j
NEXT k
END SUB
!------------------------------ ÊÔÂâ
LET p=6 !p¡ßq
LET q=8
DIM F(p+1,q) !0°Ê¾å:À¸Â¸¥Õ¥é¥°¡¢¥Ñ¥¿¡¼¥óÈÖ¹æ
MAT F=ZER
DATA 4, 4, 4, 4, 4, 4, 4, 4 !¥Ñ¥¿¡¼¥óÈֹ桡¢¨¶ö¿ô
DATA 4, 4, 4, 4, 4, 4, 4, 4
DATA 6, 6, 6, 6, 6, 6, 6, 6
DATA 6, 6, 6, 6, 6, 6, 6, 6
DATA 2, 2, 2, 2, 2, 2, 2, 2
DATA 2, 2, 2, 2, 2, 2, 2, 2
DATA 6, 6, 6, 6, 6, 6, 6, 6 !ÀèƬ¤ÎÈÖ¹æ
MAT READ F
LET ox=n+2 !µ¡ÂΤδֳÖ
LET oy=m+2
LET lx=vx-ox*q !ÊÔÂâ¤Îº¸¾å°ÌÃÖ
LET ly=4
PICTURE BLOCK(v$,m,n) !¥¤¥ó¥Ù¡¼¥À¡¼¤Ê¤É¤ò°ÌÃÖ(0,0)-(n,m)¤Ëɽ¼¨¤¹¤ë
FOR i=0 TO m-1 !m¡ßn¥É¥Ã¥È
FOR j=0 TO n-1
LET k=i*n+j+1
IF v$(k:k)<>" " THEN DRAW DOT WITH SHIFT(V2W(j),V2W(i))
NEXT j
NEXT i
END PICTURE
LET DX=-1 !°ÜÆ°Êý¸þ
LET FLG=0 !µ¡ÂΤÎÆ°ºî
LET Invaded=0 !¿¯Î¬¾õ¶·
DO !¥²¡¼¥à¥ë¡¼¥×
!------------------------------ Åö¤êȽÄê¡Ê²¾¡Ë
MOUSE POLL mx,my,left,right !¥Þ¥¦¥¹¤Î¾õÂÖ¤òÆÀ¤ë
IF left=1 THEN !º¸¥Ü¥¿¥ó²¡²¼¤Ê¤é
LET x=W2V(mx)-lx !ÊÔÂâ¤ÎÎΰèÆâ¤Ê¤é
LET y=W2V(my)-ly
IF x<0 OR x>=ox*q OR y<0 OR y>=oy*p THEN
ELSE
LET xx=MOD(x,ox) !µ¡ÂÎÆâ¤Ê¤é
LET yy=MOD(y,oy)
IF xx<n AND yy<m THEN
LET xx=INT(x/ox)+1 !³ºÅö¤¹¤ëµ¡ÂΤòÇúȯ¢ª¾ÃÌǤ¹¤ë
LET yy=INT(y/oy)+1
IF F(yy,xx)>=2 THEN LET F(yy,xx)=1
END IF
END IF
END IF
!------------------------------ ÉÁ²è½èÍýËè¡Ê¥Õ¥ì¡¼¥à¤òɽ¼¨¤¹¤ë¡Ë
SET DRAW mode hidden !¤Á¤é¤Ä¤Ëɻ߳«»Ï
CLEAR
LET CntOfEnemy=0
FOR x=1 TO q !¥¤¥ó¥Ù¡¼¥À¡¼·²¤òɽ¼¨¤¹¤ë
IF F(p+1,x)>0 THEN !¤³¤ÎÎó¤Ëµ¡ÂΤ¬Â¸ºß¤¹¤ë¤Ê¤é
LET xx=lx+ox*(x-1)
LET F(p+1,x)=0
FOR y=1 TO p
LET ptn=F(y,x) !À¸Â¸¤Ê¤é
IF ptn>=0 THEN
LET idx=INT(ptn/2) !¥Ñ¥¿¡¼¥ó¤òÁªÂò¤¹¤ë
LET koma=MOD(ptn,2)
DRAW BLOCK(ptn$(idx+1,koma+1),m,n) WITH SHIFT(V2W(xx),V2W(ly+oy*(y-1)))
IF ptn=1 THEN
LET F(y,x)=-1 !Çúȯ¢ª¾ÃÌÇ
ELSE
LET F(y,x)=MOD(ptn+1,2)+idx*2 !¤Ñ¤¿¤Ñ¤¿¥¢¥Ë¥á¡¼¥·¥ç¥ó
LET F(p+1,x)=y !ÀèƬ¤ÎÈÖ¹æ¤ò¹¹¿·¤¹¤ë
IF ly+oy*(y-1)>vy*2/3 THEN LET Invaded=1 !¿¯Î¬¤·¤¿¤Ê¤é
END IF
LET CntOfEnemy=CntOfEnemy+1 !µ¡ÂΤοô
END IF
NEXT y
IF F(p+1,x)>0 THEN !¤³¤ÎÎó¤Ëµ¡ÂΤ¬¤¢¤ì¤Ð
IF FLG=0 THEN !ÀÞ¤êÊÖ¤·¤ò³Îǧ¤¹¤ë
IF xx<=0 OR xx+n>=vx THEN LET FLG=1 !º¸Ã¼¡¢±¦Ã¼¤Ê¤é
END IF
IF RND<0.1 THEN !ÃƤòȯ¼Í¤¹¤ë
FOR y=1 TO NumOfBeam !̤ȯ¼Í¤òõ¤¹
IF BM(y,3)<0 THEN
LET BM(y,1)=xx+INT(n/2)
LET BM(y,2)=ly+oy*(F(p+1,x)-1)+INT(m/2)
LET BM(y,3)=0 !»ÈÍÑÃæ
EXIT FOR !£±Îó¤Ë£±¤Ä¤º¤Ä
END IF
NEXT y
END IF
END IF
END IF
NEXT x
FOR y=1 TO NumOfBeam !ÃƤòɽ¼¨¤¹¤ë
LET ptn=BM(y,3)
IF ptn>=0 THEN !»ÈÍÑÃæ¤Ê¤é
DRAW BLOCK(bm$(1,ptn+1),3,2) WITH SHIFT(V2W(BM(y,1)),V2W(BM(y,2)))
LET BM(y,3)=MOD(ptn+1,2) !¤Ñ¤¿¤Ñ¤¿¥¢¥Ë¥á¡¼¥·¥ç¥ó
END IF
NEXT y
SET DRAW mode explicit !¤Á¤é¤Ä¤Ëɻ߽ªÎ»
!------------------------------ °ÜÆ°½èÍý¡Ê¼¡¤Î¥Õ¥ì¡¼¥à¤Ø¡Ë
SELECT CASE FLG !¥¤¥ó¥Ù¡¼¥À¡¼¤ò°ÜÆ°¤µ¤»¤ë
CASE 0
LET lx=lx+DX !²£¤Ø°ÜÆ°¤µ¤»¤ë
CASE 1
LET ly=ly+2 !ÀÞ¤êÊÖ¤·¤ÎÆ°ºî¡Ê¹ß²¼¤µ¤»¤ë¡Ë
LET FLG=2
CASE ELSE
LET DX=-DX !¹ß²¼¸å¡¢£±¤ÄÎ¥¤¹
LET lx=lx+DX
LET FLG=0
END SELECT
FOR i=1 TO NumOfBeam !ÃƤò°ÜÆ°¤µ¤»¤ë
IF BM(i,3)>=0 THEN !»ÈÍÑÃæ¤Ê¤é
LET BM(i,2)=BM(i,2)+3 !¹ß²¼¤µ¤»¤ë
IF BM(i,2)>vy THEN LET BM(i,3)=-1 !²¼Ã¼¤Ê¤é
END IF
NEXT i
!!!WAIT DELAY 0.3
LOOP UNTIL CntOfEnemy=0 OR Invaded=1 !µ¡ÂÎÁ´ÌǤޤÇ
END
²û¤«¤·¤¤¥²¡¼¥à¤Ç¤¹¡£¡Ö¥¯¥ê¥Ã¥¯¤·¤Æ¤âÃƤ¬È¯¼Í¤µ¤ì¤Ê¤¤¡×¤È»×¤¤¤Þ¤·¤¿¤¬¡¢¥¤¥ó¥Ù¡¼¥À¡¼¤òľÀÜ¥¯¥ê¥Ã¥¯¤¹¤ë¤Î¤Ç¤¹¤Í¡£
ÊÔÂâ¤Î¤¹¤°±¦Â¦¤ò¥¯¥ê¥Ã¥¯¤¹¤ë¤È¡Öź»ú¤¬Èϰϳ°¡×¤Î¥¨¥é¡¼¤¬À¸¤¸¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£
Åö¤êȽÄê¤Î¥ë¡¼¥Á¥ó¤Ç xx=9 ¤Î¤È¤ IF F(yy,xx)>=2 THEN LET F(yy,xx)=1 ¤¬¥¨¥é¡¼¤È¤Ê¤ë¤è¤¦¤Ç¤¹¡£
x=104 ¤ò²óÈò¤¹¤ì¤Ð¤è¤¤¤Î¤Ç¡¢IF x<0 OR x>ox*q OR y<0 OR y>oy*p THEN ¤ò
IF x<0 OR x>=ox*q OR y<0 OR y>oy*p THEN ¤È¤¹¤ë¤Î¤Ï¤É¤¦¤Ç¤·¤ç¤¦¤«¡£
!¥Ö¥í¥Ã¥¯Êø¤·
DEF V2W(x)=4*x !²¾ÁÛ²èÌ̤κÂɸ¤òʪÍý²èÌ̤κÂɸ¤Ø
DEF W2V(x)=INT(x/4) !¤½¤ÎµÕ
PICTURE DOT !ʪÍý²èÌ̤˥ɥåȤòɽ¼¨¤¹¤ë
PLOT AREA: -2,-2; 2,-2; 2,2; -2,2 !4x4
END PICTURE
LET vx=100 !²¾ÁÛ²èÌ̤ÎÂ礤µ¡¡120¡ß100¥É¥Ã¥È
LET vy=120
SET bitmap SIZE V2W(vx)+1,V2W(vy)+1 !ʪÍý²èÌ̤ÎÂ礤µ
SET WINDOW 0,V2W(vx),V2W(vy),0 !¥¹¥¯¥ê¡¼¥óºÂɸ
RANDOMIZE
!------------------------------ ¥Ö¥í¥Ã¥¯
LET lx=5 !º¸¾å¤ÎºÂɸ
LET ly=20
LET ox=10 !´Ö³Ö
LET oy=6
LET p=5 !p¡ßq¸Ä
LET q=INT(vx/ox)-2
DIM B(0 TO p-1,0 TO q-1) !1:Í¡¢0:̵
MAT B=2*CON
DIM BC(2) !¾×ÆͲó¿ô¤Î¿§¡Ê¥ë¥Ã¥¯¥¢¥Ã¥×¥Æ¡¼¥Ö¥ë¡Ë
DATA 4,10
MAT READ BC
!------------------------------ ÊÉ
LET wx1=lx-1 !º¸¾å¤ÎºÂɸ
LET wy1=ly-15
LET wx2=wx1+ox*q !±¦²¼¤ÎºÂɸ
LET wy2=vy-5
!------------------------------ ¥Ñ¥Ã¥É
LET px=x !º¸¾å¤ÎºÂɸ
LET pw=5 !Éý¤ÎȾʬ
!------------------------------ ¥Ü¡¼¥ë
LET dx=3 !°ÜÆ°Êý¸þ
LET dy=5
LET x1=INT((wx2-wx1)/2) !ȯ¼Í°ÌÃÖ
LET y1=ly+oy*p + 10
LET x=x1 !¸½ºß¤Î°ÌÃÖ
LET y=y1
LET k=0
LET NumOfBlock=p*q !¥Ö¥í¥Ã¥¯¤ÎÁí¿ô
LET NumOfPad=3 !¥Ñ¥Ã¥É¤Î»Ä¤ê¿ô
DO !¥²¡¼¥à¥ë¡¼¥×
!------------------------------ Åö¤êȽÄê
IF (x<=wx1 AND x1<>wx1) THEN !º¸Â¦¤ÎÊÉ¡¡¢¨£²½Å¾×ÆÍËÉ»ß
!!!IF x<=wx1 THEN !º¸Â¦¤ÎÊÉ
LET k=0 !¥Ü¡¼¥ë¤Îµ¯ÅÀ
LET x1=wx1
LET y1=y-INT((wx1-x)*dy/dx) !°ÌÃÖ¤òÊäÀµ¡¡¢¨ÊɤΤ¹¤êÈ´¤±
LET x=x1 !¥Ü¡¼¥ë¤Î°ÌÃÖ
LET y=y1
LET dx=-dx !¥Ü¡¼¥ë¤ÎÈ¿¼Í
END IF
IF (x>=wx2 AND x1<>wx2) THEN !±¦Â¦¤ÎÊÉ
!!!IF x>=wx2 THEN !±¦Â¦¤ÎÊÉ
LET k=0
LET x1=wx2
LET y1=y-INT((x-wx2)*dy/dx)
LET x=x1
LET y=y1
LET dx=-dx
END IF
LET xx=x-lx !¥Ö¥í¥Ã¥¯¤ÎÎΰ賰¤Ê¤é
LET yy=y-ly
IF xx<0 OR xx>=ox*q OR yy<0 OR yy>=oy*p THEN
IF (y<=wy1 AND y1<>wy1) THEN !¾å¦¤ÎÊÉ
!!!IF y<=wy1 THEN !¾å¦¤ÎÊÉ
LET k=0
LET x1=x-INT((wy1-y)*dx/dy)
LET y1=wy1
LET x=x1
LET y=y1
LET dy=-dy
END IF
IF ABS(x-px)<=pw AND (y>=wy2 AND y1<>wy2) THEN !¥Ñ¥Ã¥É
!!!IF ABS(x-px)<=pw AND y>=wy2 THEN !¥Ñ¥Ã¥É
LET k=0
LET x1=x-INT((y-wy2)*dx/dy)
LET y1=wy2
LET x=x1
LET y=y1
LET dy=-dy
END IF
IF y>=vy THEN !¥ß¥¹¡ª¡ª¡ª
LET NumOfPad=NumOfPad-1
LET x=x1 !¥Ü¡¼¥ë¤Î°ÌÃÖ
LET y=y1
LET px=x !¥Ñ¥Ã¥É¤Î°ÌÃÖ
WAIT DELAY 1
END IF
ELSE !ÎΰèÆâ¤Ê¤é
!¢¨¥Ö¥í¥Ã¥¯¤ò¸ü¤¯¤¹¤ë¤È¥Ü¡¼¥ë¤¬ÆâÉô¤ËÆþ¤Ã¤¿¾õÂ֤ˤʤäơ¢²¿½Å¤Ë¤â¾×Æͤ·¤¿¤³¤È¤Ë¤Ê¤ë¡£
LET xx=INT(xx/ox) !³ºÅö¤¹¤ë¥Ö¥í¥Ã¥¯¤Î°ÌÃÖ¤ò»»½Ð¤¹¤ë
LET yy=INT(yy/oy)
IF B(yy,xx)>0 THEN !¾ÃÌǤµ¤»¤ë
LET B(yy,xx)=B(yy,xx)-1
IF B(yy,xx)=0 THEN LET NumOfBlock=NumOfBlock-1
LET k=0
LET x1=x
LET y1=y
LET dy=-dy
END IF
END IF
!------------------------------ ÉÁ²è½èÍýËè¡Ê¥Õ¥ì¡¼¥à¤òɽ¼¨¤¹¤ë¡Ë
SET DRAW mode hidden !¤Á¤é¤Ä¤Ëɻ߳«»Ï
CLEAR
SET AREA COLOR 1
FOR xx=wx1 TO wx2 !¾å¦¤ÎÊɤòɽ¼¨¤¹¤ë
DRAW DOT WITH SHIFT(V2W(xx),V2W(wy1))
NEXT xx
FOR yy=wy1 TO wy2
DRAW DOT WITH SHIFT(V2W(wx1),V2W(yy)) !º¸Â¦¡¢
DRAW DOT WITH SHIFT(V2W(wx2),V2W(yy)) !±¦Â¦
NEXT yy
FOR yy=0 TO p-1 !¥Ö¥í¥Ã¥¯
FOR xx=0 TO q-1
LET c=B(yy,xx)
IF c>0 THEN !¸ºß¤¹¤ë¤Ê¤é
SET AREA COLOR BC(c) !¥ë¥Ã¥¯¥¢¥Ã¥×¥Æ¡¼¥Ö¥ë¤ò»²¾È¤¹¤ë
DRAW BLOCK(oy-1,ox-1) WITH SHIFT(V2W(lx+ox*xx),V2W(ly+oy*yy))
END IF
NEXT xx
NEXT yy
SET AREA COLOR 1
DRAW BLOCK(2,2*pw) WITH SHIFT(V2W(px-pw),V2W(wy2)) !¥Ñ¥Ã¥É¡¡¢¨Ãæ¿´¤ÎºÂɸ¤Ç
SET AREA COLOR 2
DRAW BLOCK(3,3) WITH SHIFT(V2W(x-1),V2W(y-1)) !¥Ü¡¼¥ë¡¡¢¨Ãæ¿´¤ÎºÂɸ¤Ç
SET DRAW mode explicit !¤Á¤é¤Ä¤Ëɻ߽ªÎ»
!------------------------------ °ÜÆ°½èÍý¡Ê¼¡¤Î¥Õ¥ì¡¼¥à¤Ø¡Ë
IF ABS(dy)<ABS(dx) THEN !x¤ÎÊý¤¬Áýʬ¤¬Â¿¤¤
!¢¢¢¢¢¢¢£
!¢¢¢£¢£¢¢¡¡¡¡y=l*x+m ¤Î¼°¤È¤·¤Æ¹Í¤¨¤ë
!¢£¢¢¢¢¢¢
LET k=k+SGN(dx) !¡Þ£±¡¡°ÜÆ°ÎÌ¡¡¢¨Äã²òÁüÅÙ¤À¤È¥«¥¯¥«¥¯Æ°¤¯¤è¤¦¤Ë¸«¤¨¤ë
!!!LET k=k+SGN(dx)*3 !¡Þ£³¡¡°ÜÆ°ÎÌ
LET x=x1+k
LET y=y1+INT(k*dy/dx)
ELSE !y¤ÎÊý¤¬Áýʬ¤¬Â¿¤¤
!¢¢¢¢¢£
!¢¢¢£¢¢¡¡¡¡x=l*y+m ¤Î¼°¤È¤·¤Æ¹Í¤¨¤ë
!¢¢¢£¢¢
!¢£¢¢¢¢
LET k=k+SGN(dy) !¡Þ£±¡¡°ÜÆ°ÎÌ
!!!LET k=k+SGN(dy)*3 !¡Þ£³¡¡°ÜÆ°ÎÌ
LET x=x1+INT(k*dx/dy)
LET y=y1+k
END IF
LET px=x !¥Ñ¥Ã¥É°ÌÃ֤ϥܡ¼¥ë¤Î¿¿²¼
!!!WAIT DELAY 0.2
LOOP UNTIL NumOfPad=0 OR NumOfBlock=0 !¥Ñ¥Ã¥É¡¢¥Ö¥í¥Ã¥¯¤¬¤Ê¤¯¤Ê¤ë¤Þ¤Ç
PICTURE BLOCK(m,n) !¥Ö¥í¥Ã¥¯¤Ê¤É¤ò°ÌÃÖ(0,0)-(n,m)¤Ëɽ¼¨¤¹¤ë
PLOT AREA: -2,-2; 4*n-2,-2; 4*n-2,4*m-2; -2,4*m-2
END PICTURE
!PICTURE BLOCK(m,n) !¥Ö¥í¥Ã¥¯¤Ê¤É¤ò°ÌÃÖ(0,0)-(n,m)¤Ëɽ¼¨¤¹¤ë
! FOR i=0 TO m-1 !m¡ßn¥É¥Ã¥È
! FOR j=0 TO n-1
! DRAW DOT WITH SHIFT(V2W(j),V2W(i))
! NEXT j
! NEXT i
!END PICTURE
END
PICTURE Building(x,y,w,h,d1)
IF Zs-z<=w THEN
!---back plane
LET zY(1,1)=d_yaw(i+w/2) !£Ú¼´¥«¡¼¥Ö¤ÎÈùʬ dx/dz
LET
zY(4,1)=x+d1
!ZYÊ¿Ì̤ΣøºÂɸ
DRAW Wall((y),w,h) WITH zY
!---facade
LET
zY(4,1)=x !ZYÊ¿Ì̤ΣøºÂɸ
DRAW Wall((y),w,h) WITH zY
!---side plane
LET XYz(4,1)=d_yaw(i+w/2)*w !£Ú¼´¥«¡¼¥Ö¤Ë¤è¤ë£ø°ÜÆ°º¹Ê¬
LET
XYz(4,3)=w
!£Ú¼´ °ÜÆ°º¹Ê¬
DRAW Side(x,y,h,d1) WITH XYz
END IF
END PICTURE
!
PICTURE Wall(y,w,h)
SET AREA COLOR 8 !gray
PLOT AREA: 0,y; w,y; w,y+h; 0,y+h !(Z,Y)Ê¿Ì̤Ȥ·¤ÆÉÁ¤¯¡£
FOR y=y+h-.5 TO y+1 STEP -2.5
PLOT LINES: 0,y;
w,y
!(Z,Y)Ê¿Ì̤Ȥ·¤ÆÉÁ¤¯¡£
NEXT y
END PICTURE
!
PICTURE Side(x,y,h,d1)
SET AREA COLOR 16 !dark gray
PLOT AREA: x,y; x+d1,y; x+d1,y+h; x,y+h !°ÜÆ°Á°(X,Y)Ê¿Ì̤Ȥ·¤ÆÉÁ¤¯¡£
END PICTURE
PICTURE Road(e)
IF e< Zs-z THEN LET e=Zs-z
LET Xz(2,1)=d_yaw(i+e/2) !£Ú¼´¥«¡¼¥Ö¤ÎÈùʬ dx/dz
LET Xz(2,2)=d_pitch(i+e/2) !£Ú¼´¥Ô¥Ã¥Á¤ÎÈùʬ dy/dz
DRAW Surface(e) WITH Xz
END PICTURE
!
PICTURE Surface(e)
IF Mp(4,2)/z<=d_pitch(i+e/2) THEN
SET AREA COLOR 15
PLOT AREA: 0,0; 6,0; 6,e;
0,e
!(X,Z)Ê¿Ì̤Ȥ·¤ÆÉÁ¤¯¡£
!---center line
SET AREA COLOR 0
PLOT AREA: 2.9,0; 2.9,e; 3.1,e; 3.1,0 !(X,Z)Ê¿Ì̤Ȥ·¤ÆÉÁ¤¯¡£
ELSE
!---back side
SET AREA COLOR 2
PLOT AREA: 0,0; 6,0; 6,e;
0,e
!(X,Z)Ê¿Ì̤Ȥ·¤ÆÉÁ¤¯¡£
END IF
!---joint line
PLOT LINES: 0 ,0; 2.9,0
PLOT LINES: 3.1,0; 6 ,0
END PICTURE
PICTURE Tree
SET AREA COLOR 12 !´´
PLOT AREA:-0.075,0; 0.075,0; 0.025,3;-0.025,3
SET AREA COLOR 10
FOR w=1 TO 7 !ÍÕ
DRAW disk WITH SCALE(0.3+0.05-RND*0.1)*SHIFT(0.4-RND*0.8, 2.7+0.325-RND*0.75)
NEXT W
END PICTURE
PICTURE Sign
IF MOD(i,50)=0 THEN SET AREA COLOR 2 ELSE SET AREA COLOR 4
PLOT AREA:-0.025,0; 0.025,0; 0.025,2;-0.025,2 !pole
DRAW disk WITH SCALE(0.5)*SHIFT(0,2) !plate
!PLOT TEXT,AT -.35,1.74,USING ">%%":STR$(i) !sign
CALL Plot_7segment(0 ,2 ,0.15 ,STR$(i)) !sign( PLOT TEXT ¤¬½Å¤¤»þ)
END PICTURE
SUB Plot_7segment(x,y,s,i$) !ʸ»úÎóÃæ¿´(x,y) ʸ»ú¤Î²£Éý(s) ¿ô»ú¤Îʸ»úÎó(i$)
SET LINE COLOR 0
SET LINE width 9/z !°ìÅÀÅê±Æ¡¦½Ì¾®¤ÎÊä½þ¡£(ÀþÉý¤Ï MAT ʸ¤Ç½Ì¤Þ¤Ê¤¤)
LET w=LEN(i$)
LET s1=s ! y¼´¢¬:s1=s y¼´¢:s1=-s
LET s2=s/2
LET x=x-(w-1)*s2*1.6
FOR p=1 TO w
SELECT CASE VAL(i$(p:p))
CASE 0
PLOT LINES:x-s2,y+s;x-s2,y-s;x+s2,y-s;x+s2,y+s;x-s2,y+s
CASE 1
PLOT LINES:x,y-s;x,y+s
CASE 2
PLOT LINES:x-s2,y+s1;x+s2,y+s1;x+s2,y;x-s2,y;x-s2,y-s1;x+s2,y-s1
CASE 3
PLOT LINES:x-s2,y-s;x+s2,y-s;x+s2,y+s;x-s2,y+s
PLOT LINES:x-s2,y;x+s2,y
CASE 4
PLOT LINES:x-s2,y+s1;x-s2,y;x+s2,y
PLOT LINES:x+s2,y+s1;x+s2,y-s1
CASE 5
PLOT LINES:x+s2,y+s1;x-s2,y+s1;x-s2,y;x+s2,y;x+s2,y-s1;x-s2,y-s1
CASE 6
PLOT LINES:x+s2,y+s1;x-s2,y+s1;x-s2,y-s1;x+s2,y-s1;x+s2,y;x-s2,y
CASE 7
PLOT LINES:x-s2,y+s1;x+s2,y+s1;x+s2,y-s1
CASE 8
PLOT LINES:x-s2,y;x-s2,y-s;x+s2,y-s;x+s2,y+s;x-s2,y+s;x-s2,y;x+s2,y
CASE 9
PLOT LINES:x+s2,y;x-s2,y;x-s2,y+s1;x+s2,y+s1;x+s2,y-s1;x-s2,y-s1
CASE ELSE
END SELECT
LET x=x+s*1.6
NEXT p
SET LINE width 1
SET LINE COLOR 1
END SUB
SET bitmap SIZE 601,601
SET WINDOW -1,21,-1,21 !¥Ð¥¦¥ó¥É¤ò¸¡Æ¤¤¹¤ë¾Ý¸Â¤òÁª¤Ö
DRAW grid
LET w=5 !¥Æ¡¼¥Ö¥ë¡Ê¥³¡¼¥È¡Ë¤ÎÂ礤µ
LET h=4
FOR y=0 TO 5 !½ÄÊý¸þ¤Ø¶ÀÌÌ¥³¥Ô¡¼
FOR x=0 TO 4 !²£Êý¸þ
LET cx=x*w+w/2
LET cy=y*h+h/2
DRAW rect WITH SCALE(1-2*MOD(x,2),1-2*MOD(y,2))*SHIFT(cx,cy) !ÇÜΨSCALEÊÑ´¹¤Ç¶ÀÌÌ¥³¥Ô¡¼¤¹¤ë
PLOT TEXT ,AT cx,cy: STR$(ABS(x)+ABS(y)) !¥Ð¥¦¥ó¥É¤Î²ó¿ô¡ÊÃæ±û¡Ë
PLOT TEXT ,AT x*w+1,y*h+1: STR$(y*(w-1)+x) !¥Æ¡¼¥Ö¥ëÈÖ¹æ¡Êº¸²¼¡Ë
PLOT TEXT ,AT x*w+0.1,y*h+0.1: mid$("ABCD",MOD(x,2)+2*MOD(y,2)+1,1) !ĺÅÀ
NEXT x
NEXT y
LET ex=6 !ÌÜɸ¤Î°ÌÃÖ
LET ey=11
PLOT LINES: 0,0; ex,ey !¾å¡¢²¼¡¢±¦¤Ç¥Ð¥¦¥ó¥É¤¹¤ë
!FOR i=1 TO 50-1
! DRAW disk WITH SCALE(0.1)*SHIFT(i*ex/50,i*ey/50)
!NEXT i
PICTURE rect !¸¶ÅÀ¤ÇÂоΤÊĹÊý·Á¤òÉÁ¤¯
PLOT LINES: -w/2,-h/2; w/2,-h/2; w/2,h/2; -w/2,h/2; -w/2,-h/2
DRAW disk WITH SCALE(0.1)*SHIFT(w/2-1,h/2-1) !ÌÜɸ
END PICTURE
END
!¶ÊÀþ¾å¤Ëʸ»ú¤òɽ¼¨¤¹¤ë
SET WINDOW -5,5,-5,5
DRAW grid
SET TEXT HEIGHT 0.5
SET TEXT JUSTIFY "CENTER","BOTTOM"
DRAW TextOnPath("Abc¤¢¤¤´Á",1.5) WITH SHIFT(-2,-1)
END
EXTERNAL FUNCTION f(x) !¶ÊÀþ y=f(x)¡¡¢¨ÍÛ´Ø¿ôɽ¼¨
!LET f=ABS(x-3)
!LET f=x^3
LET f=SIN(x)
END FUNCTION
EXTERNAL PICTURE TextOnPath(s$,L) !¶ÊÀþ¾å¤Ëʸ»ú¤òɽ¼¨¤¹¤ë
IF LEN(s$)=0 OR L<=0 THEN EXIT PICTURE
LET k=1 !£ëʸ»úÌÜ
LET S=0 !¶ÊÀþy=f(x)¤Î¶è´Ö[a,b]¤ÎŤµ¡¡S=¢é[a,b]SQR(1+f'(x)^2)dx
LET H=0.05
LET i=0
DO
LET t=H*i !¥ê¡¼¥Þ¥óÏ¡¢¶èʬµáÀÑ
LET Ft=f(t)
LET df=(f(t+H)-Ft)/H !Ƴ´Ø¿ô f'(x)¡¡¢¨Èùʬ·¸¿ô¤Ë¤è¤ë
LET S=S+H*SQR(1+df*df)
IF S>=(k-1)*L THEN !ʸ»ú´Ö³Ö¤´¤È¤Ë
DRAW disk WITH SCALE(0.05)*SHIFT(t,Ft) !°ÌÃÖ¤ò°õ¤¹
SET TEXT ANGLE ANGLE(1,df) !³ÑÅÙ¤òÄ´À°¤¹¤ë
PLOT TEXT ,AT t,Ft: s$(k:k) !£ëʸ»úÌÜ
LET k=k+1 !¼¡¤Îʸ»ú¤Ø
IF k>LEN(s$) THEN EXIT PICTURE !¤¹¤Ù¤Æ¤Îʸ»ú¤òɽ¼¨¤·¤¿¤Ê¤é
ELSE
PLOT LINES: t,Ft; !¶ÊÀþ¤Îµ°À×
END IF
LET i=i+1
LOOP
END PICTURE
¡üÇÞ²ðÊÑ¿ôɽ¼¨
!¶ÊÀþ¾å¤Ëʸ»ú¤òɽ¼¨¤¹¤ë
SET WINDOW -5,5,-5,5
DRAW grid
SET TEXT HEIGHT 0.5
SET TEXT JUSTIFY "CENTER","BOTTOM"
DRAW TextOnPath("Abc¤¢¤¤´Á",1.5) WITH SHIFT(-2,-1)
END
EXTERNAL FUNCTION x(t) !¶ÊÀþ x=f(t)¡¢y=f(t)¡¡¢¨ÇÞ²ðÊÑ¿ôɽ¼¨
!!!LET x=t !y=sin(x)
LET x=3*COS(t) !Ⱦ·Â£³¤Î±ß
END FUNCTION
EXTERNAL FUNCTION y(t)
!!!LET y=SIN(t) !y=sin(x)
LET y=3*SIN(t) !Ⱦ·Â£³¤Î±ß
END FUNCTION
EXTERNAL PICTURE TextOnPath(s$,L) !¶ÊÀþ¾å¤Ëʸ»ú¤òɽ¼¨¤¹¤ë
IF LEN(s$)=0 OR L<=0 THEN EXIT PICTURE
LET k=1 !£ëʸ»úÌÜ
LET S=0 !¶ÊÀþx=f(t),y=g(t)¤Î¶è´Ö[a,b]¤ÎŤµ¡¡S=¢é[a,b]SQR((dx/dt)^2+(dy/dt)^2)dx
LET H=0.05
LET i=0
DO
LET t=H*i !¥ê¡¼¥Þ¥óÏ¡¢¶èʬµáÀÑ
LET Xt=x(t)
LET Yt=y(t)
LET dx=(x(t+H)-Xt)/H !Ƴ´Ø¿ô dx/dt¡¢dy/dt¡¡¢¨Èùʬ·¸¿ô¤Ë¤è¤ë
LET dy=(y(t+H)-Yt)/H
LET w=dx*dx+dy*dy
LET S=S+H*SQR(w)
IF S>=(k-1)*L THEN !ʸ»ú´Ö³Ö¤´¤È¤Ë
DRAW disk WITH SCALE(0.05)*SHIFT(Xt,Yt) !°ÌÃÖ¤ò°õ¤¹
IF w<>0 THEN !³ÑÅÙ¤òÄ´À°¤¹¤ë
SET TEXT ANGLE ANGLE(dx,dy)
ELSE
SET TEXT ANGLE 0
END IF
PLOT TEXT ,AT Xt,Yt: s$(k:k) !£ëʸ»úÌÜ
LET k=k+1 !¼¡¤Îʸ»ú¤Ø
IF k>LEN(s$) THEN EXIT PICTURE !¤¹¤Ù¤Æ¤Îʸ»ú¤òɽ¼¨¤·¤¿¤Ê¤é
ELSE
PLOT LINES: Xt,Yt; !¶ÊÀþ¤Îµ°À×
END IF
LET i=i+1
LOOP
END PICTURE
¡ü¶ËºÂɸɽ¼¨
!¶ÊÀþ¾å¤Ëʸ»ú¤òɽ¼¨¤¹¤ë
SET WINDOW -5,5,-5,5
DRAW grid
SET TEXT HEIGHT 0.5
SET TEXT JUSTIFY "CENTER","BOTTOM"
DRAW TextOnPath("Abc¤¢¤¤´Á",3.5) WITH SHIFT(-2,-1)
END
EXTERNAL FUNCTION r(t) !¶ÊÀþ r=f(¦È)¡¡¢¨¶ËºÂɸɽ¼¨
LET r=3*(1+COS(t))
END FUNCTION
EXTERNAL PICTURE TextOnPath(s$,L) !¶ÊÀþ¾å¤Ëʸ»ú¤òɽ¼¨¤¹¤ë
IF LEN(s$)=0 OR L<=0 THEN EXIT PICTURE
LET k=1 !£ëʸ»úÌÜ
LET S=0 !¶ÊÀþr=f(¦È)¤Î¶è´Ö[a,b]¤ÎŤµ¡¡S=¢é[a,b]SQR(r(¦È)^2+r'(¦È)^2)dx
LET H=0.05
LET i=0
DO
LET t=H*i !¥ê¡¼¥Þ¥óÏ¡¢¶èʬµáÀÑ
LET Rt=r(t)
LET dr=(r(t+H)-Rt)/H !Ƴ´Ø¿ô r'(¦È)¡¡¢¨Èùʬ·¸¿ô¤Ë¤è¤ë
LET w=Rt*Rt+dr*dr
LET S=S+H*SQR(w)
LET x=Rt*COS(t) !¶ËºÂɸ(r,¦È)¢ªÄ¾¸òºÂɸ(x,y)
LET y=Rt*SIN(t)
IF S>=(k-1)*L THEN !ʸ»ú´Ö³Ö¤´¤È¤Ë
DRAW disk WITH SCALE(0.05)*SHIFT(x,y) !°ÌÃÖ¤ò°õ¤¹
IF w<>0 THEN !³ÑÅÙ¤òÄ´À°¤¹¤ë
SET TEXT ANGLE ANGLE(dr,Rt)+t
!SET TEXT ANGLE ANGLE(dr-Rt*TAN(t),Rt+dr*TAN(t))
ELSE
SET TEXT ANGLE 0
END IF
PLOT TEXT ,AT x,y: s$(k:k) !£ëʸ»úÌÜ
LET k=k+1 !¼¡¤Îʸ»ú¤Ø
IF k>LEN(s$) THEN EXIT PICTURE !¤¹¤Ù¤Æ¤Îʸ»ú¤òɽ¼¨¤·¤¿¤Ê¤é
ELSE
PLOT LINES: x,y; !¶ÊÀþ¤Îµ°À×
END IF
LET i=i+1
LOOP
END PICTURE
LET t=fnV("1234",10)
PRINT t
LET t=fnV("567",10)
PRINT t
LET s$=fnS$(11,2)
PRINT s$
LET s$=fnS$(14,2)
PRINT s$
END
EXTERNAL FUNCTION fnV(s$,p)
LET L=LEN(s$)
IF L=0 THEN EXIT FUNCTION
LET fnV=fnV(s$(1:L-1),p)*p + VAL(s$(L:L))
END FUNCTION
EXTERNAL FUNCTION fnS$(n,p)
IF n=0 THEN EXIT FUNCTION
LET fnS$=fnS$(INT(n/p),p) & STR$(MOD(n,p))
END FUNCTION
¤â¤Ã¤Èñ½ã¤ÊÎã¤Ç¤¹¡£
10 DECLARE EXTERNAL FUNCTION f
20 PRINT f(0)
30 PRINT f(1)
40 PRINT f(0)
50 END
60 EXTERNAL FUNCTION f(x)
70 IF x=0 THEN EXIT FUNCTION
80 LET f=1
90 END FUNCTION
½½¿ÊBASIC¤òºî¤ê»Ï¤á¤¿¤³¤í(¤¿¤Ö¤ó¸½ºßÇÛÉÛ¤·¤Æ¤¤¤ëWindows95ÈǤޤÇ)¤Ï´Ø¿ôÄêµÁ¤ÎÌá¤êÃͤò¥¹¥¿¥Ã¥¯¾å¤Ë³ÎÊݤ·¤Æ¤¤¤Þ¤·¤¿¤¬¡¤¤½¤ì¤Ç¤Ïµ¬³Ê¤Ë¹ç¤ï¤Ê¤¤¤Î¤Ç¡¤¸½ºß¤Î¥Ð¡¼¥¸¥ç¥ó¤ÏÀÅŪ¤ÊÊÑ¿ô¤òÍѤ¤¤Æ¤¤¤Þ¤¹¡£
µ¬³Ê¤Ç¤Ï¡¤¡ÖÄêµÁ´Ø¿ô̾¤ËºÇ¸å¤ËÂåÆþ¤µ¤ì¤¿Ã͡פȤʤäƤ¤¤Þ¤¹¡£¤Þ¤¿¡¤ÄêµÁ´Ø¿ô̾¤Ïʸˡ¾å¡¤ÊÑ¿ô¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡Ê¤À¤«¤é¶É½êÊÑ¿ô¤Ç¤â¤Ê¤¤¡Ë¡£¤·¤¿¤¬¤Ã¤Æ¡¤º£²ó¤Î¸Æ¤Ó½Ð¤·¤ÇÃͤòÀßÄꤷ¤Ê¤¤¤È¡¤Á°²óÀßÄꤷ¤¿ÃͤòÊÖ¤¹¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£
ºÇ¸å¤ËÄêµÁ´Ø¿ô̾¤ËÂåÆþ¤µ¤ì¤¿Ãͤò´Ø¿ôÃͤȤ¹¤ë¤¿¤á¡¤
10 DECLARE EXTERNAL FUNCTION f
20 PRINT f(2)
30 END
40 EXTERNAL FUNCTION f(x)
50 LET f=x
60 IF x=2 THEN LET y=f(x-1)
70 END FUNCTION
¤Î¼Â¹Ô·ë²Ì¤Ï2¤Ç¤Ê¤¯1¤Ë¤Ê¤ê¤Þ¤¹¡£
! ¼Í±ÆÊÑ´¹¡¡sample\transfo9.basÄɲÃ
DIM T(4,4)
MAT READ T
DATA 1, 0, 0, -0.25
DATA 0, 1, 0, 0.2
DATA 0, 0, 1, 0
DATA 0, 0, 0, 1
PICTURE House
SET AREA COLOR 15
PLOT AREA: 0, 1; 0, 0; 2, 0; 2, 1 ! ÊÉ
SET AREA COLOR 2
PLOT AREA: -0.6,1; 2.6, 1; 2, 2; 0, 2 ! ²°º¬
SET AREA COLOR 10
PLOT AREA: 0.1, 0; 0.1,0.8; 0.5,0.8; 0.5, 0 ! ¥É¥¢
SET AREA COLOR 5
PLOT AREA: 1.4,0.4; 1.9,0.4; 1.9,0.8; 1.4,0.8 ! Áë
SET AREA COLOR 12
PLOT AREA: 1.7, 2; 1.7,2.3; 1.5,2.3; 1.5, 2 ! ±ìÆÍ
SET TEXT HEIGHT 2 !<----- Â礤¯¤¹¤ë¤È£Î£Ç
PLOT TEXT ,AT 0,0: "²°º¬"
END PICTURE
SET WINDOW -5,5,-5,5
DRAW axes
DRAW House WITH T
END
SET WINDOW -5,5,-5,5
DRAW grid
!£²¤Ä¤Î¾Ã¼ºÅÀ
DATA 4,1 !¿åÊ¿Àþ¡Ê£Ø¼´¤ËÊ¿¹Ô¡Ë¤Î¾Ã¼ºÅÀ(x1,y1)
DATA -3,4 !¿âľÀþ¡Ê£Ù¼´¤ËÊ¿¹Ô¡Ë¤Î¾Ã¼ºÅÀ(x2,y2)
READ x1,y1, x2,y2
DRAW vp WITH SHIFT(x1,y1)
DRAW vp WITH SHIFT(x2,y2)
PICTURE vp !¥Þ¡¼¥«¡¼¤òÉÁ¤¯
LET a=0.125
PLOT AREA: -a,-a; a,-a; a,a; -a,a
END PICTURE
DIM M(4,4) !¾Ã¼ºÅÀ¤Ë¤Ê¤ë¤è¤¦¤ËÂæ·ÁÊÑ·Á¤¹¤ë
MAT M=IDN
LET M(1,4)=1/(x1-x2) !¾Ã¼ºÅÀ(x,0)¤Ê¤é¡¢1/x¡£¡¡x¢ª¡ç¤Ê¤é¡¢0
LET M(2,4)=1/(y2-y1) !¾Ã¼ºÅÀ(0,y)¤Ê¤é¡¢1/y¡£¡¡y¢ª¡ç¤Ê¤é¡¢0
DIM Mp(4,4)
MAT Mp=SHIFT(-x2,-y1)*M*SHIFT(x2,y1)
DRAW t WITH Mp
PICTURE t !ÊÑ·Á¤µ¤ì¤¿¿Þ·Á¤òÉÁ¤¯
PLOT LINES: -1,-1; 1,-1; 1,1; -1,1; -1,-1 !¶³¦Àþ¤òÉÁ¤¯
PLOT LINES: -1,0; 1,0 !¼´
PLOT LINES: 0,-1; 0,1
SET TEXT HEIGHT 1 !Àµµ¬ºÂɸÆâ¤Î¿Þ·Á¡¡¢«¢«¢«¢« ¤³¤³
!¢¨¡ÖÌäÂêºÂɸ¡ÊJIS¡Ë¡×¤Ç¤Ï¡¢´ûÄêÃͤ¬0.01¤Î¤¿¤á SET TEXT HEIGHT ¤Ï¤Û¤Üɬ¿Ü¤È¤Ê¤ë¡£
PLOT TEXT ,AT 0, 0: "£Æ"
PLOT TEXT ,AT -1, 0: "£²"
PLOT TEXT ,AT -1,-1: "¡÷"
PLOT TEXT ,AT 0,-1: "£Í"
END PICTURE
END
LET Pieces=5 !¶ð¤Î¿ô
LET Col=5 !ÈפÎûÊÕ¤ÎŤµ¡¡¢¨£µ¤Ï¸ÇÄê
LET Row=8 !ÈפÎĹÊÕ¤ÎŤµ
LET PieceSize=4 !¶ð¤ÎÂ礤µ
LET MaxSymmetry=8 !¶ð¤ÎÃÖ¤Êý¤ÎºÇÂç¿ô
LET MaxSite=(Col+1)*Row-1
LET LimSite=(Col+1)*(Row+1)
DIM board$(0 TO LimSite-1)
DIM NAME$(0 TO 2-1, 0 TO Pieces-1)
DIM symmetry(0 TO Pieces-1)
DIM shape(0 TO Pieces-1, 0 TO MaxSymmetry-1, 0 TO (PieceSize-1)-1)
DIM REST(0 TO Pieces-1)
LET count=0 !²òÅú¿ô
CALL initialize
CALL try(0)
SUB initialize
local site, piece, state
FOR site=0 TO MaxSite-1 !Èפò¤Ä¤¯¤ë
IF MOD(site,Col+1)=Col THEN LET board$(site)="*" ELSE LET board$(site)=""
NEXT site
FOR site=MaxSite TO (LimSite-1)-1
LET board$(site)="*"
NEXT site
LET board$(LimSite-1)="" !ÈÖ¿Í
! ¨£¨¡¨¤Col+1
! * ¨¤
! * ¨¢
! * ¨¢
! * ¨¢
! * ¨¢Row+1
! * ¨¢
! * ¨¢
! * ¨¢¢« MaxSite-1
! ***** ¨¥
! ¢¬ LimSite-1
FOR piece=0 TO Pieces-1 !¶ð¤òÆɤ߹þ¤à
LET REST(piece)=2 !£²Ë示¤Ä
READ NAME$(1,piece),NAME$(0,piece), symmetry(piece) !̾¾Î¡¢¸Ä¿ô
FOR state=0 TO symmetry(piece)-1
FOR site=0 TO (PieceSize-1)-1
READ shape(piece,state,site) !·Á¾õ
NEXT site
NEXT state
NEXT piece
END SUB
SUB found !²ò¤Îɽ¼¨
!!!local i,j
LET count=count+1
PRINT "²ò";count
FOR i=0 TO Col-1
FOR j=i TO MaxSite-1 STEP Col+1
PRINT board$(j);
NEXT j
PRINT
NEXT i
END SUB
SUB try(site) !ºÆµ¢Åª¤Ë»î¤ß¤ë
local piece,state,s0,s1,s2
LET piece=0
DO WHILE piece<Pieces !̤»ÈÍѤζð¤ËÂФ·¤Æ
IF REST(piece)=0 THEN
ELSE
LET REST(piece)=REST(piece)-1 !¤³¤Î¶ð¤ò»ÈÍѤ¹¤ë
LET state=0
DO WHILE state<symmetry(piece) !¤¹¤Ù¤Æ¤Î¸þ¤¤ËÃÖ¤¤¤Æ¤ß¤ë
LET s0=site+shape(piece,state,0)
IF board$(s0)<>"" THEN !¤³¤³¤Ë»Í³Ñ£±¤¬ÃÖ¤±¤ì¤Ð
ELSE
LET s1=site+shape(piece,state,1)
IF board$(s1)<>"" THEN !»Í³Ñ£²
ELSE
LET s2=site+shape(piece,state,2)
IF board$(s2)<>"" THEN !»Í³Ñ£³
ELSE
LET board$(site),board$(s0),board$(s1),board$(s2)=NAME$(REST(piece),piece)
LET temp=site !¼¡¤Î¶õ¤°ÌÃÖ¤òõ¤¹
DO
LET temp=temp+1
LOOP WHILE board$(temp)<>""
IF temp<MaxSite THEN CALL try((temp)) ELSE CALL found
LET board$(site),board$(s0),board$(s1),board$(s2)=""
END IF !continue
END IF
END IF
LET state=state+1
LOOP
LET REST(piece)=REST(piece)+1 !̤»ÈÍÑ
END IF !continue
LET piece=piece+1
LOOP
END SUB
!¡¡tetromin.dat -- ¥Æ¥È¥í¥ß¥Î¤Î¶ð¤Î·Á¤Î¥Ç¡¼¥¿
!ÇÛÎóborad$()¤ÎÍ×ÁÇÈÖ¹æ¤ÈÈ×¾åÇÛÃ֤Ȥδط¸
! site
! ¢
! * 1 2 3
! 4 5 6 7 8 9
! 101112131415
! 161718192021
!¡¡¨¦ Col+1 ¨¥¡¡¢¨Col=5
DATA "O","o", 1 !̾¾Î¡¢¸Ä¿ô
DATA 1,6,7 !·Á¾õ s0,s1,s2
DATA "I","i", 2
DATA 1,2,3
DATA 6,12,18
DATA "T","t", 4
DATA 1,2,7
DATA 5,6,7
DATA 5,6,12
DATA 6,7,12
DATA "Z","z", 4
DATA 1,5,6
DATA 1,7,8
DATA 5,6,11 !΢
DATA 6,7,13
DATA "L","l", 8
DATA 1,2,6
DATA 1,2,8
DATA 1,6,12
DATA 1,7,13
DATA 4,5,6 !΢
DATA 6,7,8
DATA 6,11,12
DATA 6,12,13
END
!Åê¹Æ¡Êµ½ÒÎã¡Ë¡¢¾ðÊó¡¢¥¢¥ë¥´¥ê¥º¥à¡¢¥Ñ¥º¥ë¡¢°Ü¿¢
! PLOT TEXT ʸ»ú¤Î¡¢¶ÀÁü¥Æ¥¹¥È¡£
!
!-------------------
LET N=1 !0,1,2, Ä̾ï¤ÎËü²Ú¶À¤Ï£²¤Ë¤¹¤ë¡£
LET NN=2^N
SET TEXT JUSTIFY "center","half"
SET TEXT BACKGROUND "OPAQUE"
ASK PIXEL SIZE (0,0;1,1) xx,yy
LET xx=xx/2
LET yy=yy/2
SET WINDOW -xx/NN,xx/NN, -yy/NN,yy/NN
LET ¦Õ=0
LET stp=-PI/180*6
DO
LET t=INT(TIME)
IF t0<>t THEN
LET t0=t
IF 2*PI<=ABS(¦Õ) THEN LET stp=-stp
LET ¦Õ=REMAINDER(¦Õ, 2*PI) +stp
!-----
SET DRAW mode hidden
CLEAR
SET TEXT font "Century",12*NN
DRAW D4(N) WITH SHIFT(-300/2,-300/2/SQR(3))*ROTATE(¦Õ*(-1)^N)*SCALE(1,(-1)^N)
SET TEXT font "Century",12
PLOT TEXT,AT (xx-80)/NN,(yy-10)/NN:"Right Click to Stop"
DRAW center WITH SHIFT(-300/2/NN,-300/2/SQR(3)/NN)*ROTATE(¦Õ)
SET DRAW mode explicit
END IF
WAIT DELAY 0 !¡¡¾ÊÅÅÎϸú²Ì
MOUSE POLL mx,my,mlb,mrb
LOOP UNTIL mrb>=1 !¡¡±¦¥¯¥ê¥Ã¥¯¤ÇÄä»ß
PICTURE center
SET LINE COLOR 2
SET LINE width 2
PLOT LINES:0,0; 300/NN,0; 300/2/NN,300*SQR(3)/2/NN; 0,0
SET LINE width 1
SET LINE COLOR 1
END PICTURE
!------
PICTURE D4(k)
IF 0< k THEN
DRAW D4(k-1) WITH SCALE(1/2,1/2)*SHIFT(300/4,SQR(3)*300/4) !¡¡Æ⦤ξå
DRAW D4(k-1) WITH SCALE(1/2,-1/2)*SHIFT(300/4,SQR(3)*300/4) !¡¡Æ⦤ÎÃæ
DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(-PI*2/3)*SHIFT(300/4,SQR(3)*300/4) !Æ⦤κ¸
DRAW D4(k-1) WITH SCALE(1/2,1/2)*ROTATE(PI*2/3)*SHIFT(300,0) !¡¡Æ⦤α¦
ELSE
DRAW A_Clock WITH ROTATE(-¦Õ)*SHIFT(300/2,300/2/SQR(3))
PLOT LINES:0,0; 300,0; 300/2,300*SQR(3)/2; 0,0 !¡¡³°Â¦¤Î´ð½à»°³Ñ·Á
END IF
END PICTURE
!------
PICTURE A_Clock
SET AREA COLOR 1
FOR i=1 TO 60
LET a=-PI/30*(i-15)
IF MOD(i,5)=0 THEN
PLOT TEXT,AT
60*COS(a)+.5, 60*SIN(a)
:STR$(i/5)
!¿ô»ú
! CALL Plot_7segment( 60*COS(a) ,60*SIN(a) ,5.5 ,STR$(i/5)) !¿ô»ú(ÂåÂØ)
END IF
DRAW disk WITH SCALE(1-.5*SGN(MOD(i,5)))*SHIFT(72*COS(a),72*SIN(a)) !ʬÌÜÀ¹¤ê
NEXT i
!---
DRAW hand(1) WITH SCALE(2.5, 0.75)*ROTATE(-t*PI/21600) !»þ¿Ë
DRAW hand(1) WITH
ROTATE(-t*PI/1800)
!ʬ¿Ë
DRAW hand(1) WITH SCALE(0, 1.1)*ROTATE(-t*PI/30) !ÉÿË
DRAW disk WITH
SHIFT(0,0)*SCALE(4)
!Ãæ¿´¤Î¾þ¤ê
END PICTURE
PICTURE hand(c)
SET AREA COLOR c
PLOT AREA: -1,-15; 1,-15; 1,60; -1,60 !£³¿Ë¶¦ÍÑ¡¢£°»þ°ÌÃ֤οË
END PICTURE
!--------------------------------------------------------------------------
SUB Plot_7segment(x,y,s,i$) !ʸ»úÎóÃæ¿´(x,y) ʸ»ú¤Î²£Éý(s) ¿ô»ú¤Îʸ»úÎó(i$)
LET w=LEN(i$)
LET s1=s ! y¼´¢¬:s1=s y¼´¢:s1=-s
LET s2=s/2
LET x=x-(w-1)*s2*1.6
FOR p=1 TO w
SELECT CASE VAL(i$(p:p))
CASE 0
PLOT LINES:x-s2,y+s;x-s2,y-s;x+s2,y-s;x+s2,y+s;x-s2,y+s
CASE 1
PLOT LINES:x,y-s;x,y+s
CASE 2
PLOT LINES:x-s2,y+s1;x+s2,y+s1;x+s2,y;x-s2,y;x-s2,y-s1;x+s2,y-s1
CASE 3
PLOT LINES:x-s2,y-s;x+s2,y-s;x+s2,y+s;x-s2,y+s
PLOT LINES:x-s2,y;x+s2,y
CASE 4
PLOT LINES:x-s2,y+s1;x-s2,y;x+s2,y
PLOT LINES:x+s2,y+s1;x+s2,y-s1
CASE 5
PLOT LINES:x+s2,y+s1;x-s2,y+s1;x-s2,y;x+s2,y;x+s2,y-s1;x-s2,y-s1
CASE 6
PLOT LINES:x+s2,y+s1;x-s2,y+s1;x-s2,y-s1;x+s2,y-s1;x+s2,y;x-s2,y
CASE 7
PLOT LINES:x-s2,y+s1;x+s2,y+s1;x+s2,y-s1
CASE 8
PLOT LINES:x-s2,y;x-s2,y-s;x+s2,y-s;x+s2,y+s;x-s2,y+s;x-s2,y;x+s2,y
CASE 9
PLOT LINES:x+s2,y;x-s2,y;x-s2,y+s1;x+s2,y+s1;x+s2,y-s1;x-s2,y-s1
CASE ELSE
END SELECT
LET x=x+s*1.6
NEXT p
END SUB
LET si=11 !Àµ»°³Ñ·Á(x1,y1)(x2,y2)(x3,y3) ¤Î°ìÊÕ¡£
LET x1=1.5
LET y1=2.5
!---- !ɬ¤º¤·¤â¡¢ÅùÊդǤʤ¯¤Æ¤è¤¤¤¬¡¢³°ÊÉɽ¼¨¤Ï¥º¥ì¤ë¡£
LET x2=x1+si
LET y2=y1
LET x3=x1+si/2
LET y3=y1+SQR(3)*si/2
!---- !
£³
LET A12=(y2-y1)/(x2-x1) ! f13 ¡¿ ¡À f23
LET A13=(y3-y1)/(x3-x1) ! £±¨¡¨¡¨¡£²
LET A23=(y3-y2)/(x3-x2) ! f12
DEF f12(x)=A12*(x-x1)+y1 ! ¨¡
DEF f13(x)=A13*(x-x1)+y1 ! ¡¿
DEF f23(x)=A23*(x-x2)+y2 ! ¡À
!
!¥Ü¡¼¥ë°ÌÃÖ(bx,by)¤ÎÁ°Îò¤ÎÀþ y=my/mx*(x-bx)+by ¤ÈÊɤÎ
!
! ľÀþf12 y=A12*(x-x1)+y1 ¤È¤Î¸òÅÀ¤Î¼° A12*(x-x1)+y1=my/mx*(x-bx)+by
! x=(A12*x1-y1-bx*my/mx+by)/(A12-my/mx)
! y=f12(x)
! ľÀþf13 y=A13*(x-x1)+y1 ¤È¤Î¸òÅÀ¤Î¼° A13*(x-x1)+y1=my/mx*(x-bx)+by
! x=(A13*x1-y1-bx*my/mx+by)/(A13-my/mx)
! y=f13(x)
! ľÀþf23 y=A23*(x-x2)+y2 ¤È¤Î¸òÅÀ¤Î¼° A23*(x-x2)+y2=my/mx*(x-bx)+by
! x=(A23*x2-y2-bx*my/mx+by)/(A23-my/mx)
! y=f23(x)
!
LET px12= (x2-x1)/SQR((y2-y1)^2+(x2-x1)^2)
LET py12= (y2-y1)/SQR((y2-y1)^2+(x2-x1)^2) !ľÀþf12 ¤ËÊ¿¹Ô¤Ê¡¢Ã±°Ì¥Ù¥¯¥È¥ë
LET px13= (x3-x1)/SQR((y3-y1)^2+(x3-x1)^2)
LET py13= (y3-y1)/SQR((y3-y1)^2+(x3-x1)^2) !ľÀþf13 ¤ËÊ¿¹Ô¤Ê¡¢Ã±°Ì¥Ù¥¯¥È¥ë
LET px23= (x3-x2)/SQR((y3-y2)^2+(x3-x2)^2)
LET py23= (y3-y2)/SQR((y3-y2)^2+(x3-x2)^2) !ľÀþf23 ¤ËÊ¿¹Ô¤Ê¡¢Ã±°Ì¥Ù¥¯¥È¥ë
LET ox12= py12
LET oy12=-px12 !ľÀþf12 ¤Ë¿âľ¤Ê¡¢Ã±°Ì¥Ù¥¯¥È¥ë
LET ox13= py13
LET oy13=-px13 !ľÀþf13 ¤Ë¿âľ¤Ê¡¢Ã±°Ì¥Ù¥¯¥È¥ë
LET ox23= py23
LET oy23=-px23 !ľÀþf23 ¤Ë¿âľ¤Ê¡¢Ã±°Ì¥Ù¥¯¥È¥ë
!
LET bx=X1 !¥Ü¡¼¥ë¤Î½é´ü°ÌÃÖ
LET by=Y1
LET mx=SQR(5)/8 !¥Ü¡¼¥ë¤ÎX®ÅÙ¡¢¥¹¥Æ¥Ã¥×ùX
LET my=SQR(3)/20 !¥Ü¡¼¥ë¤ÎY®ÅÙ¡¢¥¹¥Æ¥Ã¥×ùY
!
SET WINDOW 0,14, 0,14
! DRAW grid(1,1)
SET DRAW MODE NOTXOR !£²ÅÙ½ñ¤¤Ç¾Ã¤¨¤ë NOTXOR ¥â¡¼¥É
LET r=0.7 !¥Ü¡¼¥ë¤ÎȾ·Â
!----
PLOT LINES: x1-r*SQR(3),y1-r; x2+r*SQR(3),y2-r; x3,y3+r*2; x1-r*SQR(3),y1-r !ɽ¼¨ÊÉÌÌ
SET LINE COLOR 15 !¶ä
PLOT LINES: x1,y1; x2,y2; x3,y3; x1,y1 ! ·×»»ÊÉÌÌ
SET LINE COLOR 2 !ÀÄ
SET AREA COLOR 2 !ÀÄ
!
PLOT TEXT,AT 10,13: "±¦¥¯¥ê¥Ã¥¯¡§Ää»ß"
DO
DRAW disk WITH SCALE(r)*SHIFT(bx,by) !¥Ü¡¼¥ë¤ò½ñ¤¯
! SET DRAW mode explicit
WAIT DELAY 0.02 !¾ÊÅÅÎϸú²Ì¤È¡¢Â®ÅÙ
! SET DRAW mode hidden
DRAW disk WITH SCALE(r)*SHIFT(bx,by) !¥Ü¡¼¥ë¤À¤±¤ò¾Ã¤¹
PLOT LINES :
bx,by; !
ÍúÎòÀþ¤ò¡Ê½ñ¤¯¡¦¾Ã¤¹¡Ë
LET bx=bx+mx
LET by=by+my
IF f23(bx)<=by THEN LET bx23=(A23*x2-y2-bx*my/mx+by)/(A23-my/mx)
IF f13(bx)<=by THEN LET bx13=(A13*x1-y1-bx*my/mx+by)/(A13-my/mx)
IF f12(bx)>=by THEN LET bx12=(A12*x1-y1-bx*my/mx+by)/(A12-my/mx)
!----
IF f23(bx)<=by AND x3<=bx23 AND bx23<=x2 THEN
LET bx=bx23
LET by=f23(bx)
LET wy=(mx*px23+my*py23)*py23-(mx*ox23+my*oy23)*oy23
LET mx=(mx*px23+my*py23)*px23-(mx*ox23+my*oy23)*ox23 !mx,my ¤Î¡¢ÊɤËÊ¿¹ÔÀ®Ê¬¡ÝÊɤ˿âľÀ®Ê¬
LET my=wy
ELSEIF f13(bx)<=by AND x1<=bx13 AND bx13<=x3 THEN
LET bx=bx13
LET by=f13(bx)
LET wy=(mx*px13+my*py13)*py13-(mx*ox13+my*oy13)*oy13
LET mx=(mx*px13+my*py13)*px13-(mx*ox13+my*oy13)*ox13
LET my=wy
ELSEIF f12(bx)>=by AND x1<=bx12 AND bx12<=x2 THEN
LET bx=bx12
LET by=f12(bx)
LET wy=(mx*px12+my*py12)*py12-(mx*ox12+my*oy12)*oy12
LET mx=(mx*px12+my*py12)*px12-(mx*ox12+my*oy12)*ox12
LET my=wy
END IF
MOUSE POLL mox,moy,mlb,mrb
LOOP UNTIL 0< mrb
!»¶Ê⥳¡¼¥¹¤Îõº÷
PUBLIC NUMERIC N !Êâ¿ô
LET N=16
DIM d(N),x(0 TO N),y(0 TO N) !³ÆÊâ¿ô¤Ç¤ÎÊý¸þ¤È°ÌÃÖ
MAT d=ZER
MAT x=ZER !¸¶ÅÀ
MAT y=ZER
LET x(1)=1 !£±ÊâÌܤÏÅì¤Ø¡¡¢¨0:Åì¡¢1:ËÌ¡¢2:À¾¡¢3:Æî
CALL search(2,d,x,y) !£²ÊâÌܰʹß
END
EXTERNAL SUB search(s,d(),x(),y()) !¥Ð¥Ã¥¯¥È¥é¥Ã¥¯¤Ç¸¡º÷¤¹¤ë
FOR i=-1 TO 1 STEP 2 !±¦¤Èº¸¤Î¤ß
LET dd=MOD(d(s-1)+i,4) !£±¤ÄÁ°¤ò´ð½à¤Ë¤¹¤ë
LET xx=x(s-1) !¸½ºß¤Î°ÌÃÖ
LET yy=y(s-1)
SELECT CASE dd !sÊâÌܤΰÜÆ°µ÷Î¥
CASE 0 !E
LET xx=xx+s
CASE 1 !N
LET yy=yy+s
CASE 2 !W
LET xx=xx-s
CASE 3 !S
LET yy=yy-s
CASE ELSE
END SELECT
LET x(s)=xx !¿Ê¤á¤ë
LET y(s)=yy
LET d(s)=dd !sÊâÌܤÎÊý¸þ
IF s=N THEN !»ØÄê¤ÎÊâ¿ô¤Ë㤷¤¿¤é
IF x(N)=x(0) AND y(N)=y(0) THEN !¸µ¤Î°ÌÃÖ¤ËÌá¤Ã¤¿¤é
MAT PRINT d;
SET bitmap SIZE 600,600 !ºî²è¤·¤Æ¸òº¹¤Ê¤É¤ò³Îǧ¤¹¤ë
SET WINDOW -40,40,-40,40
CLEAR
DRAW grid(5,5)
SET LINE width 2
SET TEXT HEIGHT 1.5 !¢¨Ä´À°¤¬É¬ÍפǤ¢¤ë
SET TEXT JUSTIFY "center","half"
FOR k=1 TO N
SET LINE COLOR 1 !´ñ¿ô¤È¶ö¿ô¤Ç¿§Ê¬¤±
IF MOD(k,2)=0 THEN SET LINE COLOR 4
PLOT LINES: x(k-1),y(k-1); x(k),y(k) !µ°À×
PLOT TEXT ,AT (x(k-1)+2*x(k))/3,(y(k-1)+2*y(k))/3: STR$(k)
NEXT k
SET LINE width 1 !restore it
pause !OK?
!INPUT PROMPT "OK¤«NG¤òÆþÎϤ·¤Æ¤¯¤À¤µ¤¤¡£": y$
END IF
ELSE
CALL search(s+1,d,x,y) !¼¡¤Ø
END IF
NEXT i
END SUB
!²óÅú¡¢¾ðÊó¡¢¥¢¥ë¥´¥ê¥º¥à¡¢¥Ñ¥º¥ë
OPTION BASE 0
SET WINDOW -7,7, -7,7
DRAW axes
!----
LET
ma=9 !¿³Ñ·Á¤Î ³Ñ¿ô
3,4,5,6,7,8,,,,
DIM x(ma),y(ma),A(ma),px(ma),py(ma)
LET r=0.7 !¥Ü¡¼¥ë¤ÎȾ·Â
LET
r0=5.5 !·×»»¤Ç»ÈÍѤΠ¿³Ñ·Á¡¢³°ÀܱߤÎȾ·Â
LET r1=r0+r/SIN(PI/2-PI/ma) !¥Ü¡¼¥ë¤ÎÅö¤ë ¿³Ñ·Á¡¢³°ÀܱߤÎȾ·Â
!
!LET a0=PI*(1.5-1/ma) !(x1,y1)¤Î³Ñ¡£
LET a0=PI*(1.5-3/ma) !(x1,y1)¤Î£±¤Ä¼êÁ°¤Î³Ñ¡£
FOR i=0 TO ma
LET x(i)=r0*COS(a0)
LET y(i)=r0*SIN(a0)
IF 0< i THEN
SET LINE COLOR "silver"
PLOT LINES: x(i-1),y(i-1); x(i),y(i) !·×»»ÊÉÌÌ
SET LINE COLOR "black"
PLOT LINES: r1/r0*x(i-1),r1/r0*y(i-1); r1/r0*x(i),r1/r0*y(i) !¥Ü¡¼¥ëÊÉÌÌ
END IF
LET a0=a0+2*PI/ma
NEXT i
! A3
A4 £´ A3
!
£³ £´¨¡¨¡£³ £µ¡¿ ¡À£³
! A3 ¡¿ ¡À A2
A4¨¢ ¨¢A2
A5¡À ¡¿A2 ¡¦¡¦¡¦
! £±¨¡¨¡¨¡£² £±¨¡¨¡£² £±¨¡£²
!
A1
A1
A1
!
FOR i=1 TO ma
LET j=MOD(i,ma)+1
LET
A(i)=(y(j)-y(i))/(x(j)-x(i))
!ľÀþij ¤Î¸ûÇÛ
LET px(i)=(x(j)-x(i))/SQR((y(j)-y(i))^2+(x(j)-x(i))^2)
LET py(i)=(y(j)-y(i))/SQR((y(j)-y(i))^2+(x(j)-x(i))^2) !ľÀþij ¤ËÊ¿¹Ô¤Ê¡¢Ã±°Ì¥Ù¥¯¥È¥ë
NEXT i
!
LET a0=ANGLE(x(1),y(1))
LET bx=r0*COS(a0)*0.999 ! ¥Ü¡¼¥ë¤Î½é´ü°ÌÃÖX
LET by=r0*SIN(a0)*0.999 ! ¥Ü¡¼¥ë¤Î½é´ü°ÌÃÖY
LET a0=ANGLE(x(2)-x(1),y(2)-y(1))+SQR(2)*PI/ma/1.1313 !¥Ü¡¼¥ë¤Î½é´ü³ÑÅÙ
LET m0=.23 !¥Ü¡¼¥ë¤Î®¤µù
LET mx=m0*COS(a0) !¥Ü¡¼¥ë¤Î½é´üùX
LET my=m0*SIN(a0) !¥Ü¡¼¥ë¤Î½é´üùY
SUB Cross !³ÆÊդؤξ×Æ͸¡½Ð¤ÈÈ¿¼Í
LET ok=0
IF ABS(A(n))< 1 THEN
!---ÊɤÎľÀþ(y-y0)=(x-x0)*A ,¥Ü¡¼¥ë°ÌÃ֤ȿÞÃæ¿´¤ò·ë¤ÖÀþ y=x*by/bx ¤Î¸òÅÀ(xw,yw)¡£
LET
xw=(x(n)*A(n)-y(n))/(A(n)-by/bx) !xw
Í¥Àè
LET yw=(xw-x(n))*A(n)+y(n)
IF 0< xw*bx+yw*by AND
xw^2+yw^2<=bx^2+by^2 THEN !Êɤγ°
!---ÊɤÎľÀþ(y-y0)=(x-x0)*A, ¥Ü¡¼¥ëµ°À×Àþ(y-by)=(x-bx)*my/mx ¤Î¸òÅÀ(xc,yc)¡£
LET xc=(x(n)*A(n)-y(n)-bx*my/mx+by)/(A(n)-my/mx) !xc Í¥Àè
LET yc=(xc-x(n))*A(n)+y(n)
!---ÊɤΰìÊÕÆâ¤Ê¤é¡¢È¿¼Í½èÍý
IF (x(n)<=xc AND
xc<=x(MOD(n,ma)+1) OR x(MOD(n,ma)+1)<=xc AND xc<=x(n)) THEN
CALL Mirror
END IF
ELSE
!---ÊɤÎľÀþ(y-y0)=(x-x0)*A ,¥Ü¡¼¥ë°ÌÃ֤ȿÞÃæ¿´¤ò·ë¤ÖÀþ y=x*by/bx ¤Î¸òÅÀ(xw,yw)¡£
LET
yw=(y(n)/A(n)-x(n))/(1/A(n)-bx/by) !yw
Í¥Àè
LET xw=(yw-y(n))/A(n)+x(n)
IF 0< xw*bx+yw*by AND
xw^2+yw^2<=bx^2+by^2 THEN !Êɤγ°
!---ÊɤÎľÀþ(y-y0)=(x-x0)*A, ¥Ü¡¼¥ëµ°À×Àþ(y-by)=(x-bx)*my/mx ¤Î¸òÅÀ(xc,yc)¡£
LET yc=(y(n)/A(n)-x(n)-by*mx/my+bx)/(1/A(n)-mx/my) !yc Í¥Àè
LET xc=(Yc-y(n))/A(n)+x(n)
!---ÊɤΰìÊÕÆâ¤Ê¤é¡¢È¿¼Í½èÍý
IF (y(n)<=yc AND
yc<=y(MOD(n,ma)+1) OR y(MOD(n,ma)+1)<=yc AND yc<=y(n)) THEN
CALL Mirror
END IF
END IF
END SUB
SUB Mirror !¥Ù¥¯¥È¥ë(mx,my)¤ÎÈ¿¼Í¤ò¡¢Æ±¤¸(mx,my)¤Ë¾å½ñ¡£
LET bx=xc !¥Ü¡¼¥ë¤ò¾×ÆÍÅÀ¤ËÃÖ¤¯
LET
by=yc !
ñ°Ì¥Ù¥¯¥È¥ë¡§ÊɤËÊ¿¹Ô( px(n), py(n) )
!----
¿âľ(-py(n), px(n) )
LET wy=(mx*px(n)+my*py(n))*py(n)+(mx*py(n)-my*px(n))*px(n)
LET mx=(mx*px(n)+my*py(n))*px(n)-(mx*py(n)-my*px(n))*py(n)
LET
my=wy
!
ÆâÀÑ *Êý¸þ ÆâÀÑ *Êý¸þ
LET
ok=1 !È¿¼ÍÊó¹ð !ball®Å٥٥¯¥È¥ë£í= (mx*px+my*py)*£ð¡Ý(mx*ox+my*oy)*£ï
END
SUB !
Ê¿¹Ôñ°Ìvect.£ð ¿âľñ°Ìvect.£ï
SET LINE COLOR "blue"
SET AREA COLOR "blue"
SET DRAW MODE NOTXOR !£²ÅÙ½ñ¤¤Ç¾Ã¤¨¤ë NOTXOR ¥â¡¼¥É
!
PLOT TEXT,AT 3.7, 6.4: "±¦¥¯¥ê¥Ã¥¯¡§Ää»ß"
DO
DRAW disk WITH SCALE(r)*SHIFT(bx,by) !¥Ü¡¼¥ë¤ò½ñ¤¯
! SET DRAW mode
explicit
!¤Á¤é¤Ä¤Ëɻߡ£| ¤«¤Ê¤ê¤ÊÉé²Ù¤¬¡¢¤«¤«¤ê¤Þ¤¹¡£ÃÙ¤¤|
! SET DRAW mode
hidden
!¤Á¤é¤Ä¤Ëɻߡ£| ¥Ñ¥½¥³¥ó¤ä¾ÊÅÅÎϤʤé»È¤ï¤Ê¤¤¤¬ÎÉ|
WAIT DELAY
0.02 !
¾ÊÅÅÎϸú²Ì¤È¡¢Â®ÅÙ
DRAW disk WITH SCALE(r)*SHIFT(bx,by) !¥Ü¡¼¥ë¤À¤±¤ò¾Ã¤¹
PLOT LINES :
bx,by; !
ÍúÎòÀþ¤ò¡Ê½ñ¤¯¡¦¾Ã¤¹¡Ë
LET bx=bx+mx
LET by=by+my
!----
FOR n=1 TO ma
CALL Cross !¾×Æ͸¡½Ð¤ÈÈ¿¼Í
IF ok=1 THEN EXIT FOR
NEXT n
MOUSE POLL mox,moy,mlb,mrb
LOOP UNTIL 0< mrb
LET cEps=1e-13 !ÀºÅÙ
DIM t(2) !ºî¶ÈÍÑ
SET bitmap SIZE 600,600
SET WINDOW -5,5,-5,5
DRAW grid
LET iter=200 !·«¤êÊÖ¤·²ó¿ô
LET M=3 !£í³Ñ·Á¡¡¢¨£³°Ê¾å¤ÎÀ°¿ô
DIM Pw(M,4) !ÊÉÌ̤Îü
!DATA 3,-4, 3, 4 !ÀµÊý·Á¡¡»ÏÅÀ(x1,y1)¡¢½ªÅÀ(x2,y2)
!DATA 3, 4, -3, 4
!DATA -3, 4, -3,-4
!DATA -3,-4, 3,-4
!MAT READ Pw
!MAT PRINT Pw;
LET R=4 !³°ÀܱߤÎȾ·Â
FOR i=1 TO M !£Ø¼´¾å¤ÎÅÀ(R,0)¤«¤éÈ¿»þ·×¤Þ¤ï¤ê¤ËĺÅÀ¤òÆÀ¤ë
LET th=2*PI*(i-1)/M !»ÏÅÀ(x1,y1)
LET Pw(i,1)=R*COS(th)
LET Pw(i,2)=R*SIN(th)
LET th=2*PI*i/M !½ªÅÀ(x2,y2)
LET Pw(i,3)=R*COS(th)
LET Pw(i,4)=R*SIN(th)
NEXT i
MAT PRINT Pw;
DIM w(M,2) !ÊÉÌ̤ÎË¡Àþ¥Ù¥¯¥È¥ë
FOR i=1 TO M !Àþʬ¤ÎÊý¸þ¥Ù¥¯¥È¥ë¤«¤é»»½Ð¤¹¤ë
LET t(1)=-(Pw(i,4)-Pw(i,2)) !£ØÊý¸þ
LET t(2)= Pw(i,3)-Pw(i,1) !£ÙÊý¸þ
CALL Vec2Normalize(t,t) !Àµµ¬²½
MAT PRINT t;
LET w(i,1)=t(1)
LET w(i,2)=t(2)
NEXT i
FOR i=1 TO M !ÊÉÌ̤òɽ¼¨¤¹¤ë
PLOT LINES: Pw(i,1),Pw(i,2); Pw(i,3),Pw(i,4)
NEXT i
!¥Ü¡¼¥ë¤Îµ°Æ»¡¡Ä¾Àþp(t)=Pa+t*a
DIM a(2) !¥Ü¡¼¥ë¤Î°ÜÆ°Êý¸þ¥Ù¥¯¥È¥ë
DATA 1,2
MAT READ a
CALL Vec2Normalize(a,a) !|a|=1
MAT PRINT a;
DIM Pa(2) !¥Ü¡¼¥ë¤Îȯ¼Í°ÌÃÖ
DATA 1,0
MAT READ Pa
DIM Pc(2) !¾×ÆÍ°ÌÃÖ
DIM aa(2) !È¿¼ÍÊý¸þ¥Ù¥¯¥È¥ë
FOR k=1 TO iter !¥Ð¥¦¥ó¥É¤µ¤»¤ë
CALL CalcCollision(Pc,aa)
MAT PRINT Pc; !debug
PLOT LINES: Pa(1),Pa(2); Pc(1),Pc(2) !µ°ÀפòÉÁ¤¯
MAT Pa=Pc !¼¡¤Ø
MAT a=aa
NEXT k
!¾×Æͤ¹¤ëÊ¿Ì̤ÎË¡Àþ¥Ù¥¯¥È¥ë¤òn¡¢Æþ¼ÍÊý¸þ¥Ù¥¯¥È¥ë¤òa¤È¤¹¤ë¡£
!È¿¼ÍÊý¸þ¥Ù¥¯¥È¥ëb¤Ï¡¢b=a-2*(a¡¦n)*n
!
!¤Þ¤¿¡¢Ê¿Ì̾å¤ÎǤ°Õ¤ÎÅÀ¤òPs¡¢Æþ¼ÍÊý¸þ¥Ù¥¯¥È¥ëa¤Î»ÏÅÀ¤òPa¤È¤¹¤ë¤È¡¢
!¾×ÆÍ°ÌÃÖPc¤Ï¡¢Pc=Pa+{n¡¦(Ps-Pa)/(a¡¦n)}*a
SUB CalcReflection(a(),n(), b()) !È¿¼Í¥Ù¥¯¥È¥ë¤ò·×»»¤¹¤ë
MAT t=(2*DOT(a,n))*n !¥Ù¥¯¥È¥ëa¤ò¥Ù¥¯¥È¥ën¤Ë¼Í±Æ¤·¤Æ¡¢¤½¤Î£²ÇܤΥ٥¯¥È¥ë
MAT b=a-t
MAT PRINT b; !debug
END SUB
SUB CalcCollision(Pc(),b()) !ÊÉÌ̤Ȥξ×ÆÍ°ÌÃÖ¤ÈÈ¿¼ÍÊý¸þ¥Ù¥¯¥È¥ë¤ò·×»»¤¹¤ë
DIM n(2),Ps(2),Pe(2)
FOR i=1 TO M
CALL Vec2Set(w(i,1),w(i,2), n) !Ë¡Àþ¥Ù¥¯¥È¥ë
CALL Vec2set(Pw(i,1),Pw(i,2), Ps) !Ê¿Ì̾å¤ÎǤ°Õ¤ÎÅÀ
PRINT "ÊÉÌÌ=";i !debug
LET an=DOT(a,n) !¥Ù¥¯¥È¥ë£á¤È¥Ù¥¯¥È¥ë£î¤È¤Î¤Ê¤¹³Ñ¤òÆÀ¤ë¡¡|a||n|cos¦È<0
IF an<0 THEN !¾×Æͤ¹¤ëÊÉÌ̤Îɽ΢ȽÄê
MAT t=Ps-Pa
LET nT=DOT(n,t)
IF nT<0 THEN !ÊÉÌ̤ȤΰÌÃÖ´Ø·¸¤«¤é
MAT t=(nT/an)*a
MAT Pc=Pa+t !¸òÅÀ
CALL Vec2Set(Pw(i,3),Pw(i,4), Pe) !ľÀþ¤Î½ªÅÀ
LET v=InRange(Pc, Ps,Pe)
IF v>=0 AND v<=1 THEN !Àþʬ¾å¤Ê¤é
MAT PRINT Pc; !debug
CALL CalcReflection(a,n, b) !È¿¼ÍÊý¸þ¥Ù¥¯¥È¥ë
EXIT SUB !£±¤Ä¸«¤Ä¤«¤ì¤Ð
ELSE
PRINT "ÊÉÌ̤αäĹ¾å¤Ç¾×Æͤ¹¤ë"
MAT PRINT Pc; !debug
END IF
ELSEIF nT=0 THEN
PRINT "¾×ÆÍÃæ"
MAT PRINT Pa; !debug
MAT Pc=Pa
CALL CalcReflection(a,n, b) !È¿¼ÍÊý¸þ¥Ù¥¯¥È¥ë
EXIT SUB !£±¤Ä¸«¤Ä¤«¤ì¤Ð
ELSE
PRINT "¾×Æͤ·¤Ê¤¤"
END IF
ELSE
PRINT "¾×Æͤ·¤Ê¤¤..."
IF i=M THEN
PRINT "¤¹¤Ù¤Æ¤ÎÊÉÌ̤Ⱦ×Æͤ·¤Þ¤»¤ó¡£"
STOP
END IF
END IF
NEXT i
END SUB
!Ps¤ÈPe¤ò·ë¤ÖÀþʬ¤ò±äŤ·¤¿Ä¾Àþ¾å¤ÎÅÀPc¤ÈÀþʬ¤È¤Î°ÌÃÖ´Ø·¸
!0¡åt¡å1¤Ê¤é¡¢Àþʬ¾å
FUNCTION InRange(Pc(), Ps(),Pe())
DIM t1(2),t2(2)
MAT t1=Pe-Ps
MAT t2=Pc-Ps
IF ABS(t1(1))>=cEps THEN !t1(1)<>0
LET v=t2(1)/t1(1) !£ØÊý¸þ¤ÎÈæ
ELSE !¿âľÀþ
IF ABS(t1(2))>=cEps THEN !t1(2)<>0
LET v=t2(2)/t1(2) !£ÙÊý¸þ¤ÎÈæ
ELSE !£±ÅÀ
LET v=0
END IF
END IF
LET InRange=v
END FUNCTION
END
!¥Ù¥¯¥È¥ë
EXTERNAL FUNCTION Vec2Length(a()) !Ťµ |a|
LET Vec2Length=SQR(a(1)*a(1)+a(2)*a(2))
END FUNCTION
EXTERNAL SUB Vec2Normalize(a(),n()) !Àµµ¬²½ n=a/|a|
LET L=Vec2Length(a)
IF L>0 THEN MAT n=(1/L)*a
END SUB
!¤½¤Î¾
EXTERNAL SUB Vec2Set(x,y, v())
LET v(1)=x
LET v(2)=y
END SUB
!¥Õ¥¡¥ß¥³¥ó»þÂå¤Î2D RPG¤òºî¤ë
!¥Þ¥Ã¥×¤Î¹½À®
!¡¡¡ÖÀµÌ̸«²¼¤í¤·¡×·Á¼°¤Î¥Á¥Ã¥×²èÁü¤òÍÑ°Õ¤·¤Æ¡¢¥¿¥¤¥ë¾õ¤ËÇÛÃÖ¤¹¤ë¡£
!¡¡¥Õ¥£¡¼¥ë¥É¡¢¥ª¥Ö¥¸¥§¥¯¥È¤Î£²Áؤǹ½À®¤µ¤ì¤ë¡£
!¡¡¥ª¥Ö¥¸¥§¥¯¥ÈÁؤ¬°ÜÆ°²ÄǽȽÄê¤ÎÂоݤȤ¹¤ë¡£
!¥Á¥Ã¥×²èÁü
!¡¡½½¿ÊBASIC¤Ï¥Ó¥Ã¥È¥Þ¥Ã¥×²èÁü¤ò°·¤¦¤Î¤¬¶ì¼ê¤Î¤¿¤á¡¢¥Ù¥¯¥È¥ë¿Þ·Á¡ÊPLOTʸ¡Ë¤ÇÉÁ²è¤¹¤ë¡£
!¡¡£Ø¡¢£Ù¤È¤â¡Ý£±¡Á£±¤ÎÈϰϤκÂɸ¤Çɽ¸½¤·¤Æ¡¢ÉÁ²èñ°Ì¤ÏPICTUREʸ¤Ç¤Þ¤È¤á¤ë¡£
!
!¥Þ¥Ã¥×¤ÎŸ³«
!¡¡½½¿ÊBASIC¤ÎÌäÂêºÂɸ¤Ë¥Þ¥Ã¥×Á´ÂΤòDRAWʸ¤ÇÉÁ²è¤¹¤ë¡£
!¡¡¥Õ¥£¡¼¥ë¥É¡¢¥ª¥Ö¥¸¥§¥¯¥È¤Î½ç¤ËÉÁ²è¤¹¤ë¡£
!¥Þ¥Ã¥×¤Îɽ¼¨¡Ê¥Ó¥å¡¼¡Ë
!¡¡SET WINDOWSʸ¤Ç¥Ó¥å¡¼¤ò¹½À®¤·¤Æ¡¢¥Þ¥Ã¥×¤Î°ìÉô¤ò²èÌ̤Ëɽ¼¨¤¹¤ë¡£
!¥Ó¥å¡¼¤Î¥¹¥¯¥í¡¼¥ë
!¡¡£Ð£Ã¡ÊPlayer Character¡Ë¤Î¡ÖÃæ±û¸ÇÄê¡×¤ÇÄɽ¾¤¹¤ë¡£
!¥¥ã¥é¥¯¥¿¤Î°ÜÆ°
!¡¡¥Á¥Ã¥×ñ°Ì¡¢¾å²¼º¸±¦¤Î£´Êý¸þ¡£
!¡¡²¾ÁÛ¥²¡¼¥à¥Ñ¥Ã¥É¤«¤é¤ÎÆþÎϤò¥µ¥Ý¡¼¥È¤¹¤ë¡£
!¡¡¡¡°ÜÆ°¥¡¼¡§¥«¡¼¥½¥ë¥¡¼
!¡¡¡¡£Á¥Ü¥¿¥ó¡§SPACE¥¡¼
!¡¡¡¡£Â¥Ü¥¿¥ó¡§
!¥Þ¥Ã¥×¤ÎÄêµÁ
DATA 15,12 !¥Þ¥Ã¥×¤ÎÂ礤µ
READ msx,msy !¥Þ¥Ã¥×¾ðÊó¤òÆɤ߹þ¤à
DATA 1,1,1,2,2, 2,1,1,1,1, 2,2,2,1,1 !¥Á¥Ã¥×ÇÛÃÖ¾ðÊó¡Ê¥Õ¥£¡¼¥ë¥É¡Ë
DATA 1,1,1,2,2, 2,1,1,1,1, 2,2,2,1,1
DATA 1,1,1,2,2, 2,1,1,1,1, 1,1,1,1,1
DATA 1,1,1,1,2, 1,1,1,1,1, 1,1,1,1,1
DATA 1,1,1,1,1, 1,1,1,1,1, 1,1,1,1,1
DATA 1,2,2,1,1, 1,1,1,1,1, 1,1,1,1,1
DATA 1,2,2,1,1, 1,2,2,2,1, 1,1,1,1,1
DATA 2,2,1,1,1, 1,2,2,2,1, 3,3,1,1,1
DATA 2,2,1,1,1, 1,2,2,2,1, 3,2,2,1,1
DATA 2,2,2,2,1, 1,1,1,1,1, 3,2,2,1,1
DATA 2,2,2,2,1, 1,1,1,1,1, 3,3,2,1,1
DATA 1,1,1,1,1, 1,1,1,1,1, 3,3,3,1,1
DIM mapFld(msy,msx)
MAT READ mapFld
DATA 0, 0, 0, 0,12, 0, 0, 0, 0,11, 0,12,12, 0, 0 !¥Á¥Ã¥×ÇÛÃÖ¾ðÊó¡Ê¥ª¥Ö¥¸¥§¥¯¥È¡Ë
DATA 0, 0, 0, 0,12, 0, 0, 0, 0,11, 0, 0,12, 0, 0
DATA 0, 0, 0, 0,12, 0, 0, 0, 0,11, 11, 0, 0, 0, 0
DATA 0, 0, 0, 0, 0, 0, 0, 0,11,11, 0, 0, 0, 0, 0
DATA 0, 0 ,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DATA 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DATA 0,12,12, 0, 0, 0, 0, 0,12, 0, 0, 0, 0, 0, 0
DATA 0, 0,11,11, 0, 0, 0,21,12, 0, 13,13, 0, 0, 0
DATA 0,12,11,11, 0, 0, 0, 0,12, 0, 13,12, 0, 0, 0
DATA 0,12,12,12, 0, 0, 0, 0, 0, 0, 13,12,12, 0, 0
DATA 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 0
DATA 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
DIM mapObj(msy,msx)
MAT READ mapObj
!¥²¡¼¥à²èÌ̤ÎÄêµÁ
LET GAME_TITLE=1 !¥¿¥¤¥È¥ë
LET GAME_MOVE=2 !°ÜÆ°
LET GAME_TALK=3 !²ñÏÃ
LET GAME_BATTLE=4 !ÀïÆ®
LET gs=GAME_TITLE !¥¿¥¤¥È¥ë²èÌ̤«¤é
!¥Ó¥å¡¼¥Ý¡¼¥È¤ÎÄêµÁ
LET vsx=15 !¥Ó¥å¡¼¥Ý¡¼¥È¤ÎÂ礤µ¡Ê1/2¥Á¥Ã¥×ñ°Ì¡Ë
LET vsy=15
LET vx=0 !°ÌÃ֡ʺ¸²¼¡£¢¨ÌäÂêºÂɸ¡Ë
LET vy=0
!°ÜÆ°Êý¸þ¤ÎÄêµÁ
LET MOVE_NONE=-1 !¤Ê¤·
LET MOVE_RIGHT=0 !±¦
LET MOVE_UP=2 !¾å
LET MOVE_LEFT=4 !º¸
LET MOVE_DOWN=6 !²¼
!²ñÏÃʸ¤ÎÄêµÁ
DATA "¤Ï¤¸¤á¤ë¡§£Á¥Ü¥¿¥ó¡ÊSPACE¥¡¼¡Ë" !#1¡¡¢¨£´¹Ôñ°Ì
DATA "¤ª¤ï¤ë¡§ESC¥¡¼"
DATA ""
DATA "°ÜÆ°¡§½½»ú(¥«¡¼¥½¥ë¥¡¼)¡¢£Ï£Ë¡§£Á¥Ü¥¿¥ó"
DATA "" !#2
DATA ""
DATA ""
DATA ""
DATA "¥³¡¼¥Ò¡¼¥¿¥¤¥à¢ö" !#3
DATA ""
DATA "¡ÖµÙ·Æ¤ò¤È¤Ã¤¿¤é½Ðȯ¤À¡ª¡×"
DATA ""
DATA "¡Ö»ÄÇ°¡¢¤Ü¤¯¤Ï±Ë¤²¤Ê¤¤¤ó¤À¡£¡×" !#4
DATA "¡ÖÈô¤Ó±Û¤¨¤é¤ì¤Ê¤¤¤¾¡¥¡¥¡¥¡×"
DATA ""
DATA ""
DATA "" !#5
DATA ""
DATA ""
DATA ""
DIM ms$(4*5)
MAT READ ms$
DATA 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0 !¥¤¥Ù¥ó¥ÈÇÛÃÖ¾ðÊó
DATA 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0
DATA 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0
DATA 0,0,0,0,0, 0,0,0,0,0, 4,0,0,0,0
DATA 0,0,0,0,0, 0,0,0,4,4, 0,0,0,0,0
DATA 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0
DATA 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0
DATA 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0
DATA 0,0,0,0,0, 0,0,3,0,0, 0,0,0,0,0
DATA 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0
DATA 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0
DATA 0,0,0,0,0, 0,0,0,0,0, 0,0,0,0,0
DIM mapEvt(msy,msx)
MAT READ mapEvt
LET evt=0
!¥²¡¼¥à¤Î½é´ü²½
LET x=6 !¥¥ã¥é¥¯¥¿¤Î°ÌÃÖ¡Ê¥Á¥Ã¥×ñ°Ì¡Ë
LET y=5
LET d=MOVE_DOWN !¸þ¤
CALL SetViewPort !¥Ó¥å¡¼¥Ý¡¼¥È°ÜÆ°
LET t0=TIME
LET fRun=-1 !¥²¡¼¥à³«»Ï
DO WHILE fRun<0 !¥²¡¼¥à¥ë¡¼¥×
IF gs=GAME_TITLE THEN !¥¿¥¤¥È¥ë²èÌ̤ʤé
SET DRAW mode hidden !¤Á¤é¤Ä¤ËÉ»ß(³«»Ï)
CLEAR
DRAW Hiro(6,d) WITH SHIFT(vx+8,vy+8) !¥¥ã¥é¥¯¥¿
PLOT TEXT ,AT vx+6,vy+11: "¥Á¥ç¥³¥Ü¤ÎËÁ¸±"
CALL DrawSpeak(0,0)
SET DRAW mode explicit !¤Á¤é¤Ä¤ËÉ»ß(½ªÎ»)
CALL GetAButton(t0) !£Á¥Ü¥¿¥ó¤ÎÆþÎÏ
END IF
IF gs=GAME_MOVE THEN !°ÜÆ°²èÌ̤ʤé
CALL GetMoveKey(dx,dy,dr,t0) !°ÜÆ°¥¡¼¤ÎÆþÎÏ
IF dx<>0 OR dy<>0 THEN !°ÜÆ°¤Ê¤é
LET d=dr !°ÜÆ°Êý¸þ¤Ë¸þ¤¯
LET xx=x+dx !²¾¤Ë°ÜÆ°¤¹¤ë¡Ê¥Á¥Ã¥×ñ°Ì¡Ë
LET yy=y+dy
IF xx>0 AND xx<=msx AND yy>0 AND yy<=msy THEN !¥Þ¥Ã¥×Æâ¤Ç
IF mapObj(yy,xx)=0 THEN !¾ã³²Êª¤¬¤Ê¤±¤ì¤Ð
LET x=xx !¼ÂºÝ¤Ë°ÜÆ°¤µ¤»¤ë
LET y=yy
END IF
END IF
CALL SetViewPort !¥Ó¥å¡¼¥Ý¡¼¥È°ÜÆ°
LET evt=CheckEvent(mapEvt,x,y) !¥Õ¥£¡¼¥ë¥É¾å¤Î¥¤¥Ù¥ó¥È¤ò³Îǧ
END IF
CALL DrawView !¥Ó¥å¡¼É½¼¨
END IF
IF gs=GAME_TALK THEN !²ñÏòèÌ̤ʤé
CALL DrawView !¥Ó¥å¡¼É½¼¨
CALL GetAButton(t0) !£Á¥Ü¥¿¥ó¤ÎÆþÎÏ
END IF
IF GetKeyState(27)<0 THEN LET fRun=0 !ESC¥¡¼¤Ç½ªÎ»
LOOP
SUB GetMoveKey(dx,dy,dr,t0) !°ÜÆ°¥¡¼¤ÎÆþÎϤò³Îǧ¤¹¤ë
LET dx=0 !°ÜÆ°ÎÌ
LET dy=0
LET dr=MOVE_NONE !°ÜÆ°Êý¸þ
IF TIME-t0>0.2 THEN !200¥ß¥êÉ䴤ȤË
IF GetKeyState(37)<0 THEN !¤¤¤º¤ì¤«£±¤Ä¤Î¤ß
LET dx=-1
LET dr=MOVE_LEFT !º¸¥«¡¼¥½¥ë¥¡¼
ELSE
IF GetKeyState(38)<0 THEN
LET dy=-1
LET dr=MOVE_UP !¾å
ELSE
IF GetKeyState(39)<0 THEN
LET dx=1
LET dr=MOVE_RIGHT !±¦
ELSE
IF GetKeyState(40)<0 THEN
LET dy=1
LET dr=MOVE_DOWN !²¼
END IF
END IF
END IF
END IF
LET t0=TIME !¼¡¤Ø
END IF
END SUB
SUB GetAButton(t0) !£Á¥Ü¥¿¥ó¤ÎÆþÎϤò³Îǧ¤¹¤ë
IF TIME-t0>0.2 THEN !200¥ß¥êÉ䴤ȤË
IF GetKeyState(32)<0 THEN LET gs=GAME_MOVE !SPACE¥¡¼
LET t0=TIME !¼¡¤Ø
END IF
END SUB
SUB SetViewPort !¥Ó¥å¡¼¥Ý¡¼¥È¤ÎÀßÄꤹ¤ë
LET vx=2*x-vsx/2-1 !¡Ö¥¥ã¥é¥¯¥¿¤ÎÃæ±û¸ÇÄê¡×¤Ç¥Ó¥å¡¼¥Ý¡¼¥È¤òÄɽ¾¤µ¤»¤ë
LET vy=2*(msy-y)-vsy/2+1
SET WINDOW vx,vx+vsx,vy,vy+vsy
END SUB
SUB DrawView !¥Þ¥Ã¥×¡¢¥¥ã¥é¥¯¥¿¤òɽ¼¨¤¹¤ë
SET DRAW mode hidden !¤Á¤é¤Ä¤ËÉ»ß(³«»Ï)
CLEAR
CALL DrawLayer(mapFld,msx,msy) !¥Õ¥£¡¼¥ë¥É
CALL DrawLayer(mapObj,msx,msy) !¥ª¥Ö¥¸¥§¥¯¥È
DRAW Hiro(6,d) WITH SHIFT(2*x-1,2*(msy-y)+1) !¥¥ã¥é¥¯¥¿
IF gs=GAME_TALK THEN CALL DrawSpeak(evt,0) !²ñÏÃʸ
SET DRAW mode explicit !¤Á¤é¤Ä¤ËÉ»ß(½ªÎ»)
END SUB
SUB DrawSpeak(n,v) !²ñÏÃʸ¤òɽ¼¨¤¹¤ë
SET AREA COLOR 199 !¤Õ¤¤À¤·
PLOT AREA: vx+1,vy+1; vx+vsx-1,vy+1; vx+vsx-1,vy+5; vx+1,vy+5
SET LINE COLOR 1
SET LINE width 3
PLOT LINES: vx+1,vy+1; vx+vsx-1,vy+1; vx+vsx-1,vy+5; vx+1,vy+5; vx+1,vy+1
SET TEXT HEIGHT 0.4
FOR i=1 TO 4 !£´¹Ôñ°Ì
PLOT TEXT ,AT vx+2,vy+4.75-i*0.75: ms$(n+i)
NEXT i
END SUB
FUNCTION CheckEvent(e(,),x,y) !¥Õ¥£¡¼¥ë¥É¾å¤Î¥¤¥Ù¥ó¥È¤ò³Îǧ¤¹¤ë
LET a=e(y,x)
IF a>0 THEN LET gs=GAME_TALK !²ñÏòèÌ̤Ø
LET CheckEvent=4*(a-1)
END FUNCTION
END
EXTERNAL SUB DrawLayer(m(,),sx,sy) !¥ì¥¤¥ä¤òɽ¼¨¤¹¤ë
FOR j=1 TO sy !±ü¤«¤é½ç¤Ë¡ÊÀµÌ̸«²¼¤í¤·¡Ë
LET y=2*(sy-j)+1 !º¸¾å¤ò¸¶ÅÀ¡¢±¦Êý¸þ¤¬£Ø¼´¤ÎÀµ¡¢²¼Êý¸þ¤¬£Ù¼´¤ÎÀµ
FOR i=1 TO sx
LET x=2*i-1
DRAW PutChip(m(j,i)) WITH SHIFT(x,y) !¥Á¥Ã¥×¾ðÊó¤ò¤â¤È¤ËÇÛÃÖ¤¹¤ë
NEXT i
NEXT j
END SUB
EXTERNAL PICTURE PutChip(i) !ÈÖ¹æ¤ËÂбþ¤·¤¿¥Á¥Ã¥×²èÁü¤òÉÁ¤¯
IF i=1 THEN DRAW Ground
IF i=2 THEN DRAW Grass
IF i=3 THEN DRAW Rock
IF i=11 THEN DRAW Pool
IF i=12 THEN DRAW Tree
IF i=13 THEN DRAW Mount
IF i=21 THEN DRAW House
END PICTURE
!¢¨ºîÀ®´ð½à - £Ø¡¢£ÙºÂɸ¤È¤âÈϰϤÏ-1¡Á1¤È¤¹¤ë¡£¾¯¤·¤Ï¤ß½Ð¤Æ¤â¤è¤¤¡£
!¥¥ã¥é¥¯¥¿
EXTERNAL PICTURE Hiro(c,d) !¥Á¥ç¥³¥Ü
SET AREA COLOR 8
DRAW disk WITH SCALE(0.8,0.2)*SHIFT(0,-0.9) !±Æ
SET LINE width 2
SET LINE COLOR 1
PLOT LINES: -0.2,-0.3; -0.3,-0.9; -0.1,-0.9 !Â
SET AREA COLOR c
DRAW disk WITH SCALE(0.6) !ÂÎ
PLOT LINES: 0.3,-0.3; 0.4,-0.9; 0.6,-0.8 !Â
DRAW disk WITH SCALE(0.45)*SHIFT(0.4,0.4) !Ƭ
SET AREA COLOR 2
PLOT AREA: 0.7,0.5; 1,0.7; 0.7,0.7 !¤¯¤Á¤Ð¤·
SET AREA COLOR 1
DRAW disk WITH SCALE(0.08)*SHIFT(0.5,0.7) !ÌÜ
END PICTURE
!¥Õ¥£¡¼¥ë¥É
EXTERNAL PICTURE Ground !Ê¿ÃÏ
SET AREA COLOR 27
PLOT AREA: -1,-1; 1,-1; 1,1; -1,1
END PICTURE
EXTERNAL PICTURE Grass !ÁðÃÏ
SET AREA COLOR 3
PLOT AREA: -1,-1; 1,-1; 1,1; -1,1
END PICTURE
EXTERNAL PICTURE Rock !´äÃÏ
SET AREA COLOR 50
PLOT AREA: -1,-1; 1,-1; 1,1; -1,1
END PICTURE
!¥ª¥Ö¥¸¥§¥¯¥È
EXTERNAL PICTURE Tree !ÌÚ
SET AREA COLOR 10
DRAW disk WITH SCALE(0.5)*SHIFT(0,0.5) !ÍÕ
DRAW disk WITH SCALE(0.5)*SHIFT(-0.4,0) !ÍÕ
DRAW disk WITH SCALE(0.4)*SHIFT(0.5,-0.2) !ÍÕ
SET AREA COLOR 12
PLOT AREA: -0.2,-1; 0.2,-1; 0,0 !´´
END PICTURE
EXTERNAL PICTURE Pool !ÃÓ
SET AREA COLOR 5
PLOT AREA: -1,-1; 1,-1; 1,1; -1,1
END PICTURE
EXTERNAL PICTURE Mount !»³
SET AREA COLOR 240
PLOT AREA: -0.6,-1; 1,-1; 0.2,1
PLOT AREA: -1,-1; 0,-1; -0.5,0
END PICTURE
EXTERNAL PICTURE House !²È
SET AREA COLOR 15
PLOT AREA: -1,0; -1,-1; 1,-1; 1,0 !ÊÉ
SET AREA COLOR 2
PLOT AREA: -1.6,0; 1.6,0; 1,1; -1,1 !²°º¬
SET AREA COLOR 10
PLOT AREA: -0.9,-1; -0.9,-0.2; -0.5,-0.2; -0.5,-1 !¥É¥¢
SET AREA COLOR 5
PLOT AREA: 0.4,-0.6; 0.9,-0.6; 0.9,-0.2; 0.4,-0.2 !Áë
SET AREA COLOR 12
PLOT AREA: 0.7,1; 0.7,1.3; 0.5,1.3; 0.5,1 !±ìÆÍ
END PICTURE
ËÁƬ¤Îºî¿ÞÉôʬ¤Ç¡¢0 to ma ¤ò¡¢£± to ma ¤Ë¤¹¤ë¤È¡¢¿Þ¤¬
ÊѤë¤À¤±¤Ç¤Ê¤¯¡¢´Ø·¸Ìµ¤¤Æ°ºî¾õÂ֤ޤǡ¢¤ª¤«¤·¤¯¤Ê¤Ã¤Æ¤¤¤¿¤Î¤Ï¡¢¤³¤Î¤¿¤á¤Ç¤¹¡£¸½ºß¤Ï¡¢
¤½¤Î¾¤â¡¢½¤Àµ¤·¤Þ¤·¤¿¡£
!¥Ù¥¯¥È¥ë¤Ë¤è¤ëÊ¿ÌÌ´ö²¿¤Î·×»» - ÅÀ¡¢Ä¾Àþ¡ÊÀþʬ¡Ë
LET cEps=1e-13 !ÀºÅÙ
!¥Ù¥¯¥È¥ë(a1,a2)¤È¥Ù¥¯¥È¥ë(b1,b2)¤È¤Î±é»»
DEF fnDot(a1,a2, b1,b2)=a1*b1+a2*b2 !ÆâÀÑ
DEF fnCross(a1,a2, b1,b2)=fnDot(-a2,a1,b1,b2) !µ¼»÷³°ÀÑ¡¢¥Ñ¡¼¥×ÆâÀÑ¡¡a1*b2-a2*b1
DEF fnABS(a,b)=SQR(a*a+b*b) !ÀäÂÐÃÍ¡¢Â礤µ
DIM a(2),b(2),c(2),d(2) !ÅÀ£Á¡¢£Â¡¢£Ã¡¢£Ä
DATA 4, 4 !A
DATA -1, 1 !B
DATA -3, 2 !C
DATA 3,-4 !D
MAT READ A
MAT READ B
MAT READ C
MAT READ D
SET WINDOW -5,5,-5,5 !¥°¥é¥Õ¤òÉÁ¤¯
DRAW grid
SET TEXT HEIGHT 0.4
PLOT LINES: A(1),A(2); B(1),B(2) !Àþʬ£Á£Â
PLOT TEXT ,AT A(1),A(2): "£Á"
PLOT TEXT ,AT B(1),B(2): "£Â"
PLOT LINES: C(1),C(2); D(1),D(2) !Àþʬ£Ã£Ä
PLOT TEXT ,AT C(1),C(2): "£Ã"
PLOT TEXT ,AT D(1),D(2): "£Ä"
DIM s(2),t(2),u(2),v(2) !ºî¶ÈÍÑ
!ÅÀ£Á¤ÈÅÀ£Â¤òÄ̤ëľÀþ¤ÈÅÀ£Ã¤ÈÅÀ£Ä¤òÄ̤ëľÀþ¤È¤Îľ¸ò¡¦Ê¿¹ÔȽÄê
!ÆâÀѤ¬£°¤Ê¤é¡¢Ä¾¸ò¡£¡¡³°ÀѤ¬£°¤Ê¤é¡¢Ê¿¹Ô¡£
MAT s=b-a
MAT t=d-c
IF fnDot(s(1),s(2),t(1),t(2))=0 THEN PRINT "ľ¸ò"
IF fnCross(s(1),s(2),t(1),t(2))=0 THEN PRINT "Ê¿¹Ô"
!ÅÀ£Á¤ÈÅÀ£Â¤òÄ̤ëľÀþ¤ÈÅÀ£Ã¤ÈÅÀ£Ä¤òÄ̤ëľÀþ¤È¤Î¸òÅÀ
MAT s=b-a
MAT t=d-c
LET DD=fnCross(t(1),t(2),s(1),s(2))
IF DD<>0 THEN
MAT u=c-a
MAT v=( fnCross(t(1),t(2),u(1),u(2))/DD ) * s
MAT v=a+v
MAT PRINT v; !¸òÅÀ
ELSE
PRINT "Ê¿¹Ô¤Ç¤¹¡£"
END IF
!ÅÀ£Á¤ÈÅÀ£Â¤ò·ë¤ÖÀþʬ¤ÈÅÀ£Ã¤ÈÅÀ£Ä¤ò·ë¤ÖÀþʬ¤È¤Î¸òÅÀ
MAT s=b-a
MAT t=c-a
LET d1=fnCross(s(1),s(2),t(1),t(2))
!MAT s=b-a
MAT t=d-a
LET d2=fnCross(s(1),s(2),t(1),t(2))
MAT s=d-c
MAT t=a-c
LET d3=fnCross(s(1),s(2),t(1),t(2))
!MAT s=d-c
MAT t=b-c
LET d4=fnCross(s(1),s(2),t(1),t(2))
IF d1*d2<=0 AND d3*d4<=0 THEN
MAT u=b-a
MAT u=( ABS(d3)/(ABS(d3)+ABS(d4)) ) * u
MAT u=a+u
MAT PRINT u; !¸òÅÀ
ELSE
PRINT "¸òº¹¤Ê¤·"
END IF
!ÅÀ£Ã¤È¡¢ÅÀ£Á¤ÈÅÀ£Â¤òÄ̤ëľÀþ¤È¤Î°ÌÃÖ´Ø·¸
MAT s=b-a
MAT t=c-a
LET DD=fnCross(s(1),s(2),t(1),t(2))
IF DD=0 THEN
PRINT "Àþ¾å"
ELSEIF DD>0 THEN
PRINT "º¸Â¦"
ELSE
PRINT "±¦Â¦"
END IF
!ÅÀ£Ã¤¬¡¢ÅÀ£Á¤ÈÅÀ£Â¤ò·ë¤ÖÀþʬ¾å¤Ë¤¢¤ë¤«¤É¤¦¤«¤ÎȽÄê
!»°³ÑÉÔÅù¼° |a-b|¡å|a-c|+|c-b|
MAT s=a-c
MAT t=c-b
MAT u=a-b
IF fnABS(s(1),s(2))+fnAbs(t(1),t(2))<fnABS(u(1),u(2))+cEps THEN PRINT "Àþ¾å"
!ÅÀ£Ã¤È¡¢ÅÀ£Á¤ÈÅÀ£Â¤òÄ̤ëľÀþ¤È¤Îµ÷Î¥
MAT s=b-a
MAT t=c-a
PRINT ABS(fnCross(s(1),s(2),t(1),t(2))) / fnABS(s(1),s(2))
!ÅÀ£Ã¤È¡¢ÅÀ£Á¤ÈÅÀ£Â¤ò·ë¤ÖÀþʬ¤È¤Îµ÷Î¥¡ÊºÇ¶áÀÜÅÀ¡Ë
MAT s=b-a
MAT t=c-a
MAT u=c-b
IF fnDot(s(1),s(2),t(1),t(2))<cEps THEN !ÅÀ£Á³°Â¦
PRINT fnABS(t(1),t(2)) !ÅÀ£Á¤È¤Îµ÷Î¥
ELSEIF fnDot(-s(1),-s(2),u(1),u(2))<cEps THEN !ÅÀ£Â³°Â¦
PRINT fnABS(u(1),u(2)) !ÅÀ£Â¤È¤Îµ÷Î¥
ELSE !Àþʬ£Á£ÂÆâ
PRINT ABS(fnCross(s(1),s(2),u(1),u(2))) / fnABS(s(1),s(2)) !¿âÀþ
END IF
END
!Åê¹Æ¡Êµ½ÒÎã¡Ë¡¢¿ô³Ø¡¢¥Ù¥¯¥È¥ë¤È¿Þ·ÁÊýÄø¼°¡¢¥¢¥ë¥´¥ê¥º¥à¡¢¥²¡¼¥à¡¢Åö¤¿¤êȽÄê
!£³¡ß£³ËâÊý¿Ø¤Ç£³Ãʳ¬¤Ë¤Ê¤ë¤â¤Î¤ò¸¡º÷¤¹¤ë
OPTION ARITHMETIC NATIVE !CPU¥Ñ¥ï¡¼
DIM nm$(0 TO 19) !£°¡Á£±£¹
DATA "Zero" !0
DATA "One" !1
DATA "Two" !2
DATA "Three" !3
DATA "Four" !4
DATA "Five" !5
DATA "Six" !6
DATA "Seven" !7
DATA "Eight" !8
DATA "Nine" !9
DATA "Ten" !10
DATA "Eleven" !11
DATA "Twelve" !12
DATA "Thirteen" !13
DATA "Fourteen" !14
DATA "Fifteen" !15
DATA "Sixteen" !16
DATA "Seventeen" !17
DATA "Eighteen" !18
DATA "Nineteen" !19
MAT READ nm$
DIM nm2$(2 TO 9) !£²£°°Ê¾å
DATA "Twenty" !20
DATA "Thirty" !30
DATA "Fourty" !40
DATA "Fifty" !50
DATA "Sixty" !60
DATA "Seventy" !70
DATA "Eigthy" !80
DATA "Ninety" !90
MAT READ nm2$
FUNCTION f(x) !¿ôÃͤò±Ñ¸ìÆɤߤËÊÑ´¹¤¹¤ë¡¡¢¨£°¡Á£¹£¹£¹
LET v=0
IF x>=100 THEN LET v=LEN(nm$(INT(x/100))) + LEN("hundred") !É´¤Î°Ì
LET xx=MOD(x,100) !0¡Á99¤ÎÉôʬ
IF xx<>0 THEN
IF xx<20 THEN !0¡Á19¤Ê¤é
LET v=v+LEN(nm$(xx))
ELSE
LET v=v+LEN(nm2$(INT(xx/10))) !½½¤Î°Ì
LET w=MOD(xx,10) !°ì¤Î°Ì
IF w<>0 THEN LET v=v+LEN(nm$(w))
END IF
END IF
LET f=v
END FUNCTION
!------------------------------
DIM M(9) !£³¡ß£³´ðËÜ·Á
!DATA 2,9,4 !¹ç·×¤Ï¡¢15
!DATA 7,5,3
!DATA 6,1,8
!MAT READ M
MAT M=ZER
! M+a*A+b*B+c*C ¤Ë¤è¤ëÊÑ·Á¡¡¹ç·×¤Ï¡¢15+3*a ¤È¤Ê¤ë¡£
DIM A(9)
DATA +1,+1,+1
DATA +1,+1,+1
DATA +1,+1,+1
MAT READ A
DIM B(9)
DATA 0,-1,+1
DATA +1, 0,-1
DATA -1,+1, 0
MAT READ B
DIM C(9) !¢¨B¤ò90¡ë²óž
DATA +1,-1, 0
DATA -1, 0,+1
DATA 0,+1,-1
MAT READ C
LET cTRUE=-1 !¿¿
LET cFALSE=0 !µ¶
FUNCTION CheckRange(T()) !£±¡Á£¹£¹£¹
LET CheckRange=cFALSE
FOR i=1 TO 9
IF T(i)<0 OR T(i)>999 THEN EXIT FUNCTION
NEXT i
LET CheckRange=cTRUE
END FUNCTION
FUNCTION CheckUnique(T()) !Ʊ¤¸¿ô»ú¤«¤É¤¦¤«
LET CheckUnique=cFALSE
FOR i=1 TO 8
FOR j=i+1 TO 9
IF T(i)=T(j) THEN EXIT FUNCTION
NEXT j
NEXT i
LET CheckUnique=cTRUE
END FUNCTION
FUNCTION CheckSum(T()) !¹ç·×
LET CheckSum=cFALSE
LET v=3*T(5)
IF v<>T(1)+T(2)+T(3) THEN EXIT FUNCTION !²£
IF v<>T(4)+T(5)+T(6) THEN EXIT FUNCTION
IF v<>T(7)+T(8)+T(9) THEN EXIT FUNCTION
IF v<>T(1)+T(4)+T(7) THEN EXIT FUNCTION !½Ä
IF v<>T(2)+T(5)+T(8) THEN EXIT FUNCTION
IF v<>T(3)+T(6)+T(9) THEN EXIT FUNCTION
IF v<>T(1)+T(5)+T(9) THEN EXIT FUNCTION !¼Ð¤á
IF v<>T(3)+T(5)+T(7) THEN EXIT FUNCTION
LET CheckSum=cTRUE
END FUNCTION
!------------------------------
DIM T(9),TT(9)
!FOR aa=111 TO 0 STEP -1
FOR aa=0 TO 111 !¢¨
DIM Ta(9)
MAT TT=aa*A
MAT Ta=M+TT
PRINT "¹ç·×=";3*M(5)+3*aa; aa
FOR bb=0-Ta(8) TO 999-Ta(8) !¢¨
DIM Tb(9)
MAT TT=bb*B
MAT Tb=Ta+TT
FOR cc=0-Ta(8) TO 999-Ta(8) !¢¨
MAT TT=cc*C
MAT T=Tb+TT !£±Ãʳ¬ÌÜ
!IF CheckRange(T)=cTRUE AND CheckUnique(T)=cTRUE THEN !½ÅÊ£¤Ê¤·
IF CheckRange(T)=cTRUE THEN !½ÅÊ£¤¢¤ê
DIM T1(9)
MAT T1=T !save it
FOR i=1 TO 9 !£²Ãʳ¬ÌÜ
LET T(i)=f(T(i))
NEXT i
!IF CheckUnique(T)=cTRUE AND CheckSum(T)=cTRUE THEN
IF CheckSum(T)=cTRUE THEN
DIM T2(9)
MAT T2=T !save it
!!!MAT PRINT T; !debug
FOR i=1 TO 9 !£³Ãʳ¬ÌÜ
LET T(i)=f(T(i))
NEXT i
!IF CheckUnique(T)=cTRUE AND CheckSum(T)=cTRUE THEN
IF CheckSum(T)=cTRUE THEN
MAT PRINT T1;T2;T; !ËâÊý¿Ø¤òɽ¼¨¤¹¤ë
PRINT
END IF
END IF
END IF
NEXT cc
NEXT bb
NEXT aa
END
!»¶Ê⥳¡¼¥¹¤Îõº÷
DECLARE EXTERNAL FUNCTION F.F$ !³°Éô´Ø¿ô¤ÎÀë¸À
DECLARE EXTERNAL FUNCTION F2$ !³°Éô´Ø¿ô¤ÎÀë¸À
LET t0=TIME
PUBLIC NUMERIC ANSWER_COUNT !²òÅú¿ô
LET ANSWER_COUNT=0
PUBLIC NUMERIC N !Êâ¿ô
LET N=16
PUBLIC NUMERIC M !¥Þ¥Ã¥×¤ÎÂ礤µ
LET M1=0
LET M2=0
FOR i=0 TO N !¢¨2+4+6+ ¡Ä +(N-2)+N¤è¤êÂ礤¯
LET t=LEN(F$(i)) !Êâ¿ô
!!!LET t=LEN(F2$(i)) !Êâ¿ô¡¡¢«¢«¢«¢«¢«
IF MOD(i,2)=1 THEN
LET M1=M1+t
ELSE
LET M2=M2+t
END IF
NEXT i
LET M=MAX(M1,M2)
PRINT M;M1;M2
DIM map(-M TO M,-M TO M) !»¶Ê⤷¤¿¥³¡¼¥¹¡ÊÂÀסË
MAT map=(ORD("."))*CON !̤Ƨ
LET x=0 !¸½ºß°ÌÃÖ
LET y=0
!¢¨£±ÊâÌܤȣ²ÊâÌܤò¸ÇÄꤷ¤Æ¡¢²óž¤È¶ÀÌ̤òÇÓ½ü¤¹¤ë
CALL walk(F$(0),map,0,x,y, ok) !£±ÊâÌܤÏÅì¤Ø¡¡¢¨0:Åì¡¢1:ËÌ¡¢2:À¾¡¢3:Æî
!!!CALL walk(F2$(1),map,0,x,y, ok) !£±ÊâÌܤÏÅì¤Ø¡¡¢¨0:Åì¡¢1:ËÌ¡¢2:À¾¡¢3:Æî¡¡¢«¢«¢«¢«¢«
LET d=MOD(0-1,4) !¿Ê¹ÔÊý¸þ
CALL walk(F$(1),map,d,x,y, ok) !£²ÊâÌܤÏË̤Ø
!!!CALL walk(F2$(2),map,d,x,y, ok) !£²ÊâÌܤÏË̤ء¡¢«¢«¢«¢«¢«
CALL search(3,map,d,x,y) !£³ÊâÌܰʹß
IF ANSWER_COUNT=0 THEN PRINT "²òÅú¤Ê¤·"
PRINT "·×»»»þ´Ö=";time-t0
END
EXTERNAL SUB walk(s$,map(,),d,x,y, ok) !¥³¡¼¥¹¤ËÂÀפò»Ä¤¹
LET ok=0
LET L=LEN(s$)
SELECT CASE d !¿Ê¹ÔÊý¸þ¤Ë±þ¤¸¤Æ
CASE 0 !E
FOR i=1 TO L
IF map(y,x+i)<>ORD(".") THEN EXIT SUB !̤Ƨ°Ê³°¤Ê¤é
LET map(y,x+i)=ORD(s$(i:i))
NEXT i
LET x=x+L !°ÜÆ°Àè
CASE 1 !N
FOR i=1 TO L
IF map(y+i,x)<>ORD(".") THEN EXIT SUB !̤Ƨ°Ê³°¤Ê¤é
LET map(y+i,x)=ORD(s$(i:i))
NEXT i
LET y=y+L !°ÜÆ°Àè
CASE 2 !W
LET x=x-L !°ÜÆ°Àè¡¡¢¨Í½¤áÀè¤Ë
FOR i=1 TO L
IF map(y,x+i-1)<>ORD(".") THEN EXIT SUB !̤Ƨ°Ê³°¤Ê¤é
LET map(y,x+i-1)=ORD(s$(i:i))
NEXT i
CASE 3 !S
LET y=y-L !°ÜÆ°Àè¡¡¢¨Í½¤áÀè¤Ë
FOR i=1 TO L
IF map(y+i-1,x)<>ORD(".") THEN EXIT SUB !̤Ƨ°Ê³°¤Ê¤é
LET map(y+i-1,x)=ORD(s$(i:i))
NEXT i
CASE ELSE
END SELECT
LET ok=1 !À®¸ù
END SUB
EXTERNAL SUB search(s,map(,),d,x,y) !¥Ð¥Ã¥¯¥È¥é¥Ã¥¯¤Ç¸¡º÷¤¹¤ë
DECLARE EXTERNAL FUNCTION F.F$ !³°Éô´Ø¿ô¤ÎÀë¸À
DECLARE EXTERNAL FUNCTION F2$ !³°Éô´Ø¿ô¤ÎÀë¸À
LET s$=F$(s-1) !Êâ¿ô¤ò»»½Ð¤¹¤ë
!!!LET s$=F2$(s) !Êâ¿ô¤ò»»½Ð¤¹¤ë¡¡¢«¢«¢«¢«¢«
LET L=LEN(s$)
DIM mmm(-L TO L) !save map
IF MOD(s,2)=0 THEN
FOR i=-L TO L !£±Îóʬ¤Î¤ß¡Ê¥á¥â¥ê»ÈÍѤÎÀáÌó¡Ë
LET mmm(i)=map(y+i,x)
NEXT i
ELSE
FOR i=-L TO L !£±¹Ôʬ¤Î¤ß
LET mmm(i)=map(y,x+i)
NEXT i
END IF
FOR k=-1 TO 1 STEP 2 !±¦¤Èº¸¤Î¤ß
LET dd=MOD(d+k,4) !£±¤ÄÁ°¤ò´ð½à¤Ë¤·¤Æ¡¢sÊâÌܤÎÊý¸þ¤ò·è¤á¤ë
LET xx=x
LET yy=y
CALL walk(s$,map,dd,xx,yy, ok) !sÊâÌܤΰÜÆ°
IF ok=1 THEN
IF s=N THEN !»ØÄê¤ÎÊâ¿ô¤Ë㤷¤¿¤é
IF xx=0 AND yy=0 THEN !¸µ¤Î°ÌÃÖ¤ËÌá¤Ã¤¿¤é
LET ANSWER_COUNT=ANSWER_COUNT+1 !²òÅú¿ô
PRINT ANSWER_COUNT
FOR i=-M TO M !¥³¡¼¥¹¤òɽ¼¨¤¹¤ë
LET t$=""
FOR j=-M TO M
LET t$=t$ & CHR$(map(i,j))
NEXT j
PRINT t$ !£±¹Ôʬ¤ò¤Þ¤È¤á¤Æ½ÐÎϤ¹¤ë¡Ê¹â®¡Ë
NEXT i
PRINT
END IF
ELSE
CALL search(s+1,map,dd,xx,yy) !¼¡¤Ø
END IF
END IF
IF MOD(s,2)=0 THEN !restore map
FOR i=-L TO L
LET map(y+i,x)=mmm(i)
NEXT i
ELSE
FOR i=-L TO L
LET map(y,x+i)=mmm(i)
NEXT i
END IF
NEXT k
END SUB
MODULE F !±Ñ¸ìÆɤߤËÊÑ´¹¤¹¤ë
SHARE STRING nm$(0 TO 19) !£°¡Á£±£¹
DATA "Zero" !0
DATA "One" !1
DATA "Two" !2
DATA "Three" !3
DATA "Four" !4
DATA "Five" !5
DATA "Six" !6
DATA "Seven" !7
DATA "Eight" !8
DATA "Nine" !9
DATA "Ten" !10
DATA "Eleven" !11
DATA "Twelve" !12
DATA "Thirteen" !13
DATA "Fourteen" !14
DATA "Fifteen" !15
DATA "Sixteen" !16
DATA "Seventeen" !17
DATA "Eighteen" !18
DATA "Nineteen" !19
MAT READ nm$
SHARE STRING nm2$(2 TO 9) !£²£°°Ê¾å
DATA "Twenty" !20
DATA "Thirty" !30
DATA "Fourty" !40
DATA "Fifty" !50
DATA "Sixty" !60
DATA "Seventy" !70
DATA "Eigthy" !80
DATA "Ninety" !90
MAT READ nm2$
PUBLIC FUNCTION F$
EXTERNAL FUNCTION F$(x) !¿ôÃͤò±Ñ¸ìÆɤߤËÊÑ´¹¤¹¤ë¡¡¢¨£°¡Á£¹£¹
IF x<20 THEN !0¡Á19¤Ê¤é
LET v$=v$ & nm$(x)
ELSE
LET v$=v$ & nm2$(INT(x/10)) !½½¤Î°Ì
LET w=MOD(x,10) !°ì¤Î°Ì
IF w<>0 THEN LET v$=v$ & "-" & nm$(w)
END IF
LET F$=v$
END FUNCTION
END MODULE
EXTERNAL FUNCTION F2$(x) !¿ôÃͤÎŤµ
LET F2$=REPEAT$(mid$("123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",x,1),x)
END FUNCTION
!²óÅú¡¢¾ðÊó¡¢¥¢¥ë¥´¥ê¥º¥à¡¢¥Ñ¥º¥ë
LET t0=TIME
LET N=24 !°Ì¿ô
LET w=INT((N-1)/2)+1 !³µ»»
DIM A(w) !£±¡Á£î¤Þ¤Ç¤Î´ñ¿ôÎ󡢶ö¿ôÎó
LET m=0
FOR i=1 TO N
IF MOD(i,2)=1 THEN !´ñ¿ô¤Ê¤é
!IF MOD(i,2)=0 THEN !¶ö¿ô¤Ê¤é¡¡¢«¢«¢«¢«¢«
LET m=m+1
LET A(m)=i
END IF
NEXT i
redim A(m)
LET ANSWER_COUNT=0
DIM B(m)
FOR i=0 TO 2^(m-1)-1 !¥Ó¥Ã¥È¥Ñ¥¿¡¼¥ó¤Ç¸¡¾Ú¤¹¤ë¡¡¢¨MSB=0
MAT B=CON
LET t$=right$(REPEAT$("0",m)&BSTR$(i,2),m) !m·å
FOR k=1 TO LEN(t$)
IF t$(k:k)="1" THEN LET B(k)=-1 !0:1¡¢1:-1¤Ø
NEXT k
IF DOT(A,B)=0 THEN !¡Þ1*1 + ¡Þ1*3 + ¡Ä + ¡Þ1*(2*m+1)¤ò·×»»¤¹¤ë
LET ANSWER_COUNT=ANSWER_COUNT+1
!!!PRINT "DATA ";CHR$(34);t$;CHR$(34)
END IF
NEXT i
PRINT "¸Ä¿ô=";ANSWER_COUNT !´ñ¿ô¤Î¸Ä¿ô
PRINT
PRINT "·×»»»þ´Ö=";TIME-t0
END
LET
m_=15 !ºÇÂç³Ñ¿ô
LET
ma=3
!³«»Ï³Ñ¿ô
LET
m0=.23
!¥Ü¡¼¥ë¤Î®¤µù
DIM x(m_+1),y(m_+1),A(m_+1),ox(m_+1),oy(m_+1)
SET WINDOW -7,7, -7,7
SET DRAW MODE NOTXOR !£²ÅÙ½ñ¤¤Ç¾Ã¤¨¤ë NOTXOR ¥â¡¼¥É
LET
r=0.7 !¥Ü¡¼¥ë¤ÎȾ·Â
LET
r0=5.5
!·×»»¤Ç»ÈÍѤΠ¿³Ñ·Á¡¢³°ÀܱߤÎȾ·Â
DO
CLEAR
DRAW axes
LET r1=r0+r/SIN(PI/2-PI/ma) !¥Ü¡¼¥ë¤ÎÅö¤ë ¿³Ñ·Á¡¢³°ÀܱߤÎȾ·Â
LET a0=PI*(1.5-1/ma) !(x1,y1)¤Î³Ñ¡£
FOR i=1 TO ma+1
LET x(i)=r0*COS(a0)
LET y(i)=r0*SIN(a0)
IF 1< i THEN
SET LINE COLOR "silver"
PLOT LINES: x(i-1),y(i-1); x(i),y(i) !·×»»³°ÊÉ
SET LINE COLOR "black"
PLOT LINES: r1/r0*x(i-1),r1/r0*y(i-1); r1/r0*x(i),r1/r0*y(i) !¥Ü¡¼¥ë³°ÊÉ
END IF
LET a0=a0+2*PI/ma
NEXT i
! A3
A4 £´ A3
!
£³ £´¨¡¨¡£³ £µ¡¿ ¡À£³
! A3 ¡¿ ¡À A2
A4¨¢ ¨¢A2
A5¡À ¡¿A2 ¡¦¡¦¡¦
! £±¨¡¨¡¨¡£² £±¨¡¨¡£² £±¨¡£²
!
A1
A1
A1
!
FOR i=1 TO ma
LET A(i)=(y(i+1)-y(i))/(x(i+1)-x(i)) !ľÀþi~i+1 ¤Î¸ûÇÛ
LET oy(i)= (x(i+1)-x(i))/SQR((y(i+1)-y(i))^2+(x(i+1)-x(i))^2)
LET ox(i)=-(y(i+1)-y(i))/SQR((y(i+1)-y(i))^2+(x(i+1)-x(i))^2)
NEXT
i
!ľÀþi~i+1 ¤Ë¿âľ¤Êñ°Ì¥Ù¥¯¥È¥ë(º¸²óž)
CALL play00
LET ma=MOD(ma-2,m_-2)+3 !¼¡¡¹³Ñ¿ô 3,4,5,6,,,3,4,,
LOOP UNTIL 0< mrb
SUB Sensor
IF ABS(A(n))< 1 THEN !¶³¦¸ûÇÛ£±
LET xc=(x(n)*A(n)-y(n)-bx*my/mx+by)/(A(n)-my/mx) !¸òÅÀ xc Í¥Àè< 45¡ë
LET yc=(xc-x(n))*A(n)+y(n)
IF SGN(yc-by)<>SGN(my) AND SGN(x(n)-xc)<>SGN(x(n+1)-xc) THEN CALL Mirror
ELSE
LET yc=(y(n)/A(n)-x(n)-by*mx/my+bx)/(1/A(n)-mx/my) !¸òÅÀ yc Í¥Àè >=45¡ë
LET xc=(yc-y(n))/A(n)+x(n)
IF SGN(xc-bx)<>SGN(mx) AND SGN(y(n)-yc)<>SGN(y(n+1)-yc) THEN CALL Mirror
END IF
END SUB
SUB Mirror
LET i=mx*ox(n)+my*oy(n) !ox,oy: Êդ˿⾤ÇÆâ¸þ¤ ñ°Ìvector
IF 0<=i THEN EXIT SUB !¸å¸þ¤¤Î¸òÅÀ
LET mx=mx-2*i*ox(n)
LET my=my-2*i*oy(n) !È¿¼Í®ÅÙ
LET bx=xc
LET by=yc
LET nb=n !È¿¼ÍÊÕ ÍúÎò
END SUB
SET TEXT FONT "Courier New",12
PLOT TEXT, AT 3,0.4,USING "a=#.# k=#.# ": A,k
SET TEXT FONT "£Í£Ó ¥´¥·¥Ã¥¯",18
PLOT TEXT, AT 2,0.8:"¥¤¥ó¥Ñ¥ë¥¹±þÅú "
¤ß¤¿¤¤¤Ê´¶¤¸¤Ç¤É¤¦¤Ç¤·¤ç¤¦¤«¡£
100 LET N=100
110 LET c=0
120 FOR i=2 TO N
130 FOR k=2 TO i-1 !Ìó¿ô¤ò³Îǧ¤¹¤ë
140 IF MOD(i,k)=0 THEN GOTO 170 !¤Ò¤È¤Ä¤Ç¤â³ä¤êÀÚ¤ì¤ë¤Ê¤é¡¢ÁÇ¿ô¤Ç¤Ê¤¤
150 NEXT k
160 LET c=c+1 !ÁÇ¿ô
170 NEXT i
180 PRINT c !·ë²Ì¤òɽ¼¨¤¹¤ë
190 END
PLOT TEXT ,AT 0.1,0.8: "ABCabc¤¢¤¤¤¦´Á»ú" !¸µ¤Î½ñÂΤÈÂ礤µ
DRAW PlotText("£Í£Ó ÌÀÄ«","",24,"ABCabc¤¢¤¤¤¦´Á»ú") WITH SHIFT(0.1,0.7)
DRAW PlotText("£Í£Ó ÌÀÄ«","ÂÀ»ú",0,"ABCabc¤¢¤¤¤¦´Á»ú") WITH SHIFT(0.1,0.6)
DRAW PlotText("","¼ÐÂÎ",0,"ABCabc¤¢¤¤¤¦´Á»ú") WITH SHIFT(0.1,0.5)
DRAW PlotText("£Í£Ó ÌÀÄ«","ÂÀ»ú ¼ÐÂÎ",24,"ABCabc¤¢¤¤¤¦´Á»ú") WITH SHIFT(0.1,0.4)
END
EXTERNAL PICTURE PlotText(f$,a$,s,s$) !¸¶ÅÀ¤ò´ð½à¤Ë¡¢ÂÀ»ú¡ÊBold¡Ë¤ä¼ÐÂΡÊItalic¡Ë¤Çʸ»ú¤òÉÁ¤¯
IF f$<>"" OR s<>0 THEN SET TEXT font f$,s
IF POS(a$,"¼ÐÂÎ")>0 THEN LET a=0.5 ELSE LET a=0
DRAW TEXT(s$) WITH SHEAR(a)
LET dx=worldx(pixelx(0)+1) !£±¥É¥Ã¥È¤º¤é¤¹
LET dy=worldy(pixely(0)+1)
IF POS(a$,"ÂÀ»ú")>0 THEN DRAW TEXT(s$) WITH SHEAR(a)*SHIFT(dx,0)
!IF POS(a$,"ÂÀ»ú")>0 THEN DRAW TEXT(s$) WITH SHEAR(a)*SHIFT(0,dy) !¢¨É¬Íפ˱þ¤¸¤Æ
!IF POS(a$,"ÂÀ»ú")>0 THEN DRAW TEXT(s$) WITH SHEAR(a)*SHIFT(dx,dy) !¢¨É¬Íפ˱þ¤¸¤Æ
END PICTURE
EXTERNAL PICTURE TEXT(s$) !¸¶ÅÀ¤ò´ð½à¤Ëʸ»ú¤òÉÁ¤¯
PLOT TEXT ,AT 0,0: s$
END PICTURE
!Ê¿Ì̾å¤Î¥Ù¥¯¥È¥ëÊýÄø¼°¤È¤½¤Î¥°¥é¥Õ
OPTION ARITHMETIC COMPLEX
DEF v(a,b)=COMPLEX(a,b) !Ê£ÁÇ¿ô¤ÎϺ¹¡¢¼Â¿ôÇܤη׻»¤òÂбþ¤µ¤»¤ë
DEF fnDOT(a,b)=( a*conj(b) + conj(a)*b ) / 2 !ÆâÀÑ¡¡a1*b1+a2*b2
!ÀäÂÐÃÍ¡¡¥Ù¥¯¥È¥ë |a|^2=a¡¦a¡¡¡¡Ê£ÁÇ¿ô |z|^2=z*conj(z)
SET WINDOW -8,8,-8,8 !ɽ¼¨Îΰè¤òÀßÄꤹ¤ë
DRAW grid !XYºÂɸ
ASK PIXEL SIZE (-8,-8; 8,8) w,h !²èÁü¤Î½Ä²£¤ÎÂ礤µ(¥É¥Ã¥Èñ°Ì)¤òÄ´¤Ù¤ë
LET cEps=0.1 !ÀºÅÙ¡¡¢¨Ä´À°¤¬É¬ÍפǤ¢¤ë
SET POINT STYLE 1 !ÅÀ¤Î·Á¾õ
!Îã¡¡ÅÀA(1,0)¤òÄ̤ꡢÊý¸þ¥Ù¥¯¥È¥ë(2,3)¤Ç¤¢¤ëľÀþ¤ÎÊýÄø¼°¤òµá¤á¤è¡£
!»²¹Í¡¡Ê£ÁÇ¿ô¤Ë¤è¤ëɽ¸½
!¡¡ÅÀA¡Ê¦Á=a+b*i¡Ë¡¢d¡Ê¦Â=c+d*i¡Ë¤È¤¹¤ë¤È
!¡¡conj(¦Â)*z-¦Â*conj(z)=conj(¦Â)*¦Á-¦Â*conj(¦Á)
LET OA=v(1,0)
LET d=v(2,3)
FOR t=-3 TO 3 !t=[-¡ç,¡ç]¡¡¢¨ÈϰϤÏÄ´À°¤¬É¬ÍפǤ¢¤ë
LET OP=OA+t*d !(x,y)=(1,0)+t*(2,3)=(1+2*t,3*t)
PLOT LINES: Re(OP),Im(OP);
NEXT t
PLOT LINES
!Îã¡¡£²ÅÀA(2,5)¡¢B(-1,3)¤ò·ë¤ÖÀþʬAB¤ÎÊýÄø¼°¤òµá¤á¤è¡£
!»²¹Í¡¡Ê£ÁÇ¿ô¤Ë¤è¤ëɽ¸½
!¡¡ÅÀA¡Ê¦Á=a+b*i¡Ë¡¢ÅÀB¡Ê¦Â=c+d*i¡Ë¤È¤¹¤ë¤È¡¢Ä¾ÀþAB¤Ï
!¡¡(conj(¦Â)-conj(¦Á))*z+(¦Â-¦Á)*conj(z)=conj(¦Â)*¦Á-¦Â*conj(¦Á)
LET OA=v(2,5)
LET OB=v(-1,3)
FOR t=0 TO 1 !t=[0,1]
LET OP=(1-t)*OA+t*OB !(x,y)=(1-t)*(2,5)+t*(-1,3)
PLOT LINES: Re(OP),Im(OP);
NEXT t
PLOT LINES
!Îã¡¡ÅÀA(2,5)¡¢¥Ù¥¯¥È¥ën=(4,3)¤Ë¿âľ¤ÊľÀþ¤ÎÊýÄø¼°¤òµá¤á¤è¡£¡ÊÆâÀѤòÍѤ¤¤¿É½¸½¡Ë
!»²¹Í¡¡Ê£ÁÇ¿ô¤Ë¤è¤ëɽ¸½
!¡¡ÅÀA¡Ê¦Á=a+b*i¡Ë¡¢n¡Ê¦Â=c+d*i¡Ë¤È¤¹¤ë¤È
!¡¡conj(¦Â)*z+¦Â*conj(z)=conj(¦Â)*¦Á+¦Â*conj(¦Á)
LET a=v(2,5)
LET n=v(4,3)
FOR j=0 TO h !²èÌÌÁ´ÂΤòÁöºº¤¹¤ë
LET y=worldy(j) !¥É¥Ã¥È¤òxyºÂɸ¤ËÊÑ´¹¤¹¤ë
FOR i=0 TO w
LET x=worldx(i)
LET p=v(x,y) !n¡¦(p-a)=0¤È¤Ê¤ëÅÀP¤Îµ°À×
IF ABS( fnDOT(n,p-a) )<cEps THEN PLOT POINTS: x,y
NEXT i
NEXT j
!Îã¡¡ÅÀC(-1,1)¤òÃæ¿´¤È¤¹¤ëȾ·Â3¤Î±ß¤ÎÊýÄø¼°¤òµá¤á¤è¡£
!»²¹Í¡¡Ê£ÁÇ¿ô¤Ë¤è¤ëɽ¸½
!¡¡ÅÀC¡Ê¦Á=a+b*i¡Ë¤È¤¹¤ë¤È¡¢|z-¦Á|=r
LET OC=v(-1,1)
LET r=3
FOR j=0 TO h !²èÌÌÁ´ÂΤòÁöºº¤¹¤ë
LET y=worldy(j) !¥É¥Ã¥È¤òxyºÂɸ¤ËÊÑ´¹¤¹¤ë
FOR i=0 TO w
LET x=worldx(i)
LET OP=v(x,y) !|p-c|=r¤È¤Ê¤ëÅÀP¤Îµ°À×
IF ABS( ABS(OP-OC)-r )<cEps THEN PLOT POINTS: x,y
NEXT i
NEXT j
!Îã¡¡£²ÅÀA(-5,-3)¡¢B(2,4)¤òľ·Â¤È¤¹¤ë±ß¤ÎÊýÄø¼°¤òµá¤á¤è¡£¡ÊÆâÀѤòÍѤ¤¤¿É½¸½¡Ë
!»²¹Í¡¡Ê£ÁÇ¿ô¤Ë¤è¤ëɽ¸½
!¡¡ÅÀA¡Ê¦Á=a+b*i¡Ë¡¢ÅÀB¡Ê¦Â=c+d*i¡Ë¤È¤¹¤ë¤È
!¡¡arg((z-¦Á)/(z-¦Â))=¡ÞPI/2¡¡¤Þ¤¿¤Ï¡¡|z-(¦Á+¦Â)/2|=|¦Á-¦Â|/2
LET OA=v(-5,-3)
LET OB=v(2,4)
FOR j=0 TO h !²èÌÌÁ´ÂΤòÁöºº¤¹¤ë
LET y=worldy(j) !¥É¥Ã¥È¤òxyºÂɸ¤ËÊÑ´¹¤¹¤ë
FOR i=0 TO w
LET x=worldx(i)
LET OP=v(x,y) !PA¡¦PB=0¡Ê±ß¼þ³Ñ¤ÎÄêÍý¡Ë¤È¤Ê¤ëÅÀP¤Îµ°À×
IF ABS( fnDOT(OA-OP,OB-OP) )<cEps THEN PLOT POINTS: x,y
NEXT i
NEXT j
!Îã¡¡ÅÀO(0,0)¡¢A(2,0)¡¢B(1,2)¤È¤·¤Æ¡¢ÅÀP¤òOP=s*OA+t*OB¡¢¼Â¿ôs,t¤È¤¹¤ë¡£
!¡¡¡1¡ås+t¡å3¡¢0¡ås¡¢0¡åt¤ÎÈϰϤòÆ°¤¯¤È¤¡¢ÅÀP¤Î¸ºßÈϰϤò¿Þ¼¨¤»¤è¡£
!¡¡¢2*s+t=1¤òËþ¤¿¤¹¤È¤¡¢ÅÀP¤Î¸ºßÈϰϤò¿Þ¼¨¤»¤è¡£
LET OA=v(2,0)
LET OB=v(1,2)
FOR s=0 TO 3 STEP 2^(-6) !s¡å3¡¡¢¨¹ï¤ß¤ÏÄ´À°¤¬É¬ÍפǤ¢¤ë
FOR t=0 TO 3 STEP 2^(-6) !0¡ås¤è¤ê¡¢s+t¡å3¡å3+s¤È¤Ê¤ë¡£¤³¤ì¤è¤ê¡¢t¡å3
IF 1<=s+t AND s+t<=3 THEN !¡
LET OP=s*OA+t*OB
PLOT POINTS: Re(OP),Im(OP)
END IF
NEXT t
NEXT s
FOR s=-4 TO 4 STEP 2^(-6) !t=[-¡ç,¡ç]¡¡¢¨ÈϰϤȹï¤ß¤ÏÄ´À°¤¬É¬ÍפǤ¢¤ë
LET t=1-2*s !2*s+t=1¤è¤ê
LET OP=s*OA+t*OB
PLOT POINTS: Re(OP),Im(OP) !¢
NEXT s
!Îã¡¡£Ø¼´¾å¤òž¤¬¤ëȾ·Â1¤Î±ß¤Î±ß¼þ¾å¤ÎÅÀP¤Îµ°Àסʥµ¥¤¥¯¥í¥¤¥É¡Ë
LET r=1
FOR t=-3*PI TO 3*PI STEP 0.1 !¢¨ÈϰϤȹï¤ß¤ÏÄ´À°¤¬É¬ÍפǤ¢¤ë
LET OA=v(r*t,r) !Ãæ¿´A¡¢£Ø¼´¤È¤ÎÀÜÅÀB¤È¤¹¤ë¤È¡¢OB=¸ÌBP¤è¤ê
LET AP=v(-r*SIN(t),-r*COS(t))
LET OP=OA+AP !ÅÀP¤Îµ°À×
PLOT LINES: Re(OP),Im(OP);
NEXT t
PLOT LINES
END
PUBLIC NUMERIC BIAS, KETA, SIGN, EPS
INPUT PROMPT "·å¿ô=":KETA !' 2000·å¤Þ¤Ç
LET KETA = INT(KETA/4)
LET EPS = 5 !'·×»»¸íº¹Ê¬(4*EPS ·å)
LET BIAS = 0 !'10000 ^ (BIAS+1) ¤Þ¤Ç
LET KETA = KETA + EPS !'10000 ^ (-KETA) ¤Þ¤Ç
LET SIGN = -BIAS - 1 !'¿ÇÜĹ¿ôÉä¹æ A(SIGN)=1... Àµ A(SIGN)=-1...Éé
DIM A(-BIAS-1 TO KETA)
LET X=5
!'INPUT PROMPT "LOG(X) X=":X
CALL SLOG(X,A)
CALL DISPLAY2(A)
END
EXTERNAL SUB SLOG(X,S())
DIM A(-BIAS-1 TO KETA)
FOR I=1 TO 32
IF X<=2^I THEN EXIT FOR
NEXT I
IF (2^I-X)/2^I<(X-2^(I-1))/2^(I-1) THEN
CALL SLOG2(X,S)
ELSE
CALL SLOG3(X,S)
END IF
END SUB
EXTERNAL SUB SLOG2(AX, X()) !'LOG(1-T) T=1-X/2^N (0<T<=1) ¢ª LOG((2^N-X)/2^N)
IF AX < 0 THEN
PRINT "ERROR in SLOG2"
STOP
END IF
DIM U(-BIAS - 1 TO KETA), V(-BIAS - 1 TO KETA), S(-BIAS - 1 TO KETA), N(-BIAS - 1 TO KETA)
LET NN= 1
LET U(0) = 1
LET U(SIGN) = 1
LET S(SIGN) = 1
LET F = 1
DO WHILE 2 ^ F < AX
LET F = F + 1
LOOP
LET XX = 2 ^ F - AX
LET XA = 2 ^ F
CALL LN2(N)
CALL SMUL(N,F)
IF XX=0 THEN
CALL LCOPY(X,N)
EXIT SUB
END IF
DO
CALL SMUL(U,XX)
CALL SDIV(U,XA)
CALL LCOPY(V, U)
CALL SDIV(V, NN)
CALL LADD2(S, V)
LET NN = NN+ 1
LOOP UNTIL ZERO(V)<>0
CALL LSUB (N, S, X)
END SUB
EXTERNAL SUB SLOG3(XA, X()) !'LOG((T-1)/(T+1)) T=X/2^N (1<T<=2) ¢ª LOG((X-2^N)/(X+2^N))
IF XA < 0 THEN
PRINT "ERROR in SLOG3"
STOP
END IF
DIM D(-BIAS - 1 TO KETA)
DIM M(-BIAS - 1 TO KETA), S(-BIAS - 1 TO KETA)
DO
LET K=K+1
LOOP WHILE 2 ^ (K+1) < XA
IF XA - 2 ^ (K+1) = 0 THEN
CALL LN2(X)
CALL SMUL(X,K+1)
EXIT SUB
END IF
LET N = 1
CALL LCLR (X)
LET X(0) = XA - 2^K
LET X(SIGN) = 1
CALL SDIV(X,XA+2^K)
CALL LCOPY(S, X)
DO
CALL LCOPY(M, S)
CALL SMUL(X,(XA-2^K)^2)
CALL SDIV(X,(XA+2^K)^2)
CALL LCOPY(D, X)
LET N = N + 2
CALL SDIV(D, N)
CALL LADD2(S, D)
LOOP UNTIL EQUAL(M, S)<>0
CALL SMUL(S,2)
CALL LN2(D)
CALL SMUL(D,K)
CALL LADD(D,S,X)
END SUB
EXTERNAL SUB LN2(X()) !' LOG(2) (2000·åʬ)
CALL LCLR (X)
LET X(SIGN)=1
FOR I = 1 TO KETA
READ IF MISSING THEN EXIT FOR:X(I)
NEXT I
DATA
6931,4718,0559,9453,0941,7232,1214,5817,6568,0755,0013,4360,2552,5412,0680,0094,9339,3621,9696,9471,5605,8633,2699,6418,6875
DATA
4200,1481,0205,7068,5733,6855,2023,5758,1305,5703,2670,7516,3507,5961,9307,2757,0828,3714,3519,0307,0386,2389,1673,4711,2335
DATA
0115,3644,9795,5239,1204,7517,2681,5749,3206,5155,5247,3413,9525,8829,5045,3007,0953,2636,6642,6541,0423,9157,8149,5204,3740
DATA
4303,8550,0801,9441,7064,1671,5186,4471,2839,9681,7178,4546,9570,2627,1631,0645,4615,0257,2074,0248,1637,7733,8963,8550,6952
DATA
6066,8341,1372,7387,3722,9289,5649,3547,0257,6265,2098,8596,9320,1965,0585,5476,4703,3067,9365,4432,5476,3274,4951,2504,0606
DATA
9438,1471,0468,9946,5062,2016,7720,4245,2452,9612,6879,4654,6193,1651,7468,1392,6725,0410,3802,5462,5965,6869,1441,9287,1608
DATA
2938,0317,2714,3677,8265,4877,5664,8508,5674,0776,4845,1464,4399,4046,1422,6031,9309,6735,4025,7444,6070,3080,9608,5047,4866
DATA
3852,3138,1816,7675,1438,6674,7664,7890,8814,3714,1985,4942,3151,9973,5488,0375,1658,6127,5352,9166,1000,7105,3558,2498,7941
DATA
4729,5092,9311,3897,1559,9820,5654,3928,7170,0072,1808,5761,0252,3688,9213,2449,7138,9320,3784,3935,3088,7748,2597,0171,5591
DATA
0708,8236,8362,7589,8425,8918,5353,0243,6342,1436,7061,1892,3678,9192,3723,1467,2321,7205,3401,6492,5687,2747,7823,4453,5347
DATA
6481,1494,1864,2386,7767,7440,6069,5626,5737,9600,8670,7625,7199,1847,3402,2651,4628,3790,4883,0620,3306,1144,6300,7371,9489
DATA
0027,4364,3965,0025,8093,6519,4430,4119,1150,6080,9487,9306,7865,1588,7090,0605,2034,6842,9736,1938,4128,9652,5565,3968,6022
DATA
1941,2292,4207,5743,2175,7489,0977,0675,2687,1158,1705,1137,0091,5894,2665,4785,9596,4890,6530,5846,0258,6683,8294,0022,8330
DATA
0538,2074,0056,7705,3046,7870,0184,1624,0441,8833,2327,9838,6349,0015,6312,1889,5606,5055,3151,2721,9939,8332,0307,5140,8426
DATA
0914,7900,1265,1682,4344,3893,5724,7278,8205,4862,7155,2741,8772,4300,2489,7945,4019,6187,2339,8086,0831,6648,1149,0930,6675
DATA
1933,9312,8904,3164,1370,6813,9777,6498,1769,7486,8903,8877,8999,1296,5036,1927,0710,8892,6410,5230,9247,8391,7373,5012,2984
DATA
2420,4995,6893,5992,2066,0220,4654,9415,1061,3918,7885,7442,4557,7510,2068,3703,0866,6194,8089,6412,1868,0779,0208,1815,8858
DATA
0001,6881,1597,3056,1866,7619,9187,3952,0076,6719,2145,9223,6720,6025,3959,5436,5416,5531,1295,1759,8994,0056,0003,6651,3567
DATA
5690,5124,5926,8257,4394,6483,1683,3262,4901,8038,2424,0824,2314,5230,6140,9638,0570,0702,5513,8770,2681,7851,6306,9025,5137
DATA
0323,4053,8021,4501,9015,3740,2950,9942,2629,9577,9647,4271,3815,7363,8017,2987,3940,7042,4217,9972,2669,6297,9939,3127,0693
DATA 5747,2404,9338,6530,8797
END SUB
EXTERNAL SUB DISPLAY2(X()) !'ɽ¼¨
FOR K=-BIAS TO 0
IF X(K)<>0 THEN EXIT FOR
NEXT K
IF X(SIGN) = -1 THEN PRINT "- ";
IF K>=0 THEN
LET K=0
PRINT STR$(X(0));"."
ELSE
PRINT STR$(X(K));
FOR I=K+1 TO 0
LET A$=A$ & RIGHT$("000"&STR$(X(I)),4)
IF LEN(A$) = 100 THEN
PRINT A$
LET A$=""
END IF
NEXT I
IF LEN(A$) > 0 THEN
PRINT A$;"."
LET A$=""
END IF
END IF
LET S=0
FOR I=1 TO KETA-EPS
LET A$=A$ & RIGHT$("000"&STR$(X(I)),4)
IF LEN(A$) = 100 THEN
LET S=S+100
FOR J=1 TO 10
PRINT LEFT$(A$,10);" ";
IF J=5 THEN PRINT " ";
LET A$=RIGHT$(A$,LEN(A$)-10)
NEXT J
PRINT ":";S
LET A$=""
IF MOD(S,1000)=0 THEN PRINT
END IF
NEXT I
IF LEN(A$) > 0 THEN
LET S=S+LEN(A$)
LET A$=A$ & REPEAT$(" ",10)
FOR J=1 TO 9
PRINT RTRIM$(LEFT$(A$,10));" ";
IF J=5 THEN PRINT " ";
LET A$=RIGHT$(A$,LEN(A$)-10)
IF RTRIM$(A$)="" THEN EXIT FOR
NEXT J
!' PRINT ":";S
END IF
END SUB
EXTERNAL FUNCTION EQUAL(A(), B()) !'Åù¤·¤¤¤«¤É¤¦¤«
FOR I = -BIAS - 1 TO KETA-EPS
IF A(I)<>B(I) THEN
LET EQUAL=0
EXIT FUNCTION
END IF
NEXT I
LET EQUAL=-1
END FUNCTION
EXTERNAL FUNCTION ZERO(A()) !'0Ãͤ«¤É¤¦¤«
FOR I=-BIAS TO KETA-EPS
IF A(I)<>0 THEN
LET ZERO=0
EXIT FUNCTION
END IF
NEXT I
LET ZERO=-1
END FUNCTION
EXTERNAL FUNCTION GREAT(A(), B()) !'¿ÇÜĹ¿ôA > ¿ÇÜĹ¿ôB ¤Ê¤é¿¿
LET SIGNA = A(SIGN)
LET SIGNB = B(SIGN)
IF SIGNA = -1 AND SIGNB = 1 THEN
LET GREAT = 0
EXIT FUNCTION
END IF
IF SIGNA = 1 AND SIGNB = -1 THEN
LET GREAT = -1
EXIT FUNCTION
END IF
FOR I = -BIAS TO KETA
IF SIGNA = -1 AND SIGNB = -1 THEN
IF A(I) < B(I) THEN
LET GREAT = -1
EXIT FUNCTION
END IF
IF A(I) > B(I) THEN
LET GREAT = 0
EXIT FUNCTION
END IF
ELSE
IF A(I) > B(I) THEN
LET GREAT = -1
EXIT FUNCTION
END IF
IF A(I) < B(I) THEN
LET GREAT = 0
EXIT FUNCTION
END IF
END IF
NEXT I
END FUNCTION
EXTERNAL SUB LCLR(A()) !'0ÃÍ¥»¥Ã¥È
MAT A=ZER
LET A(SIGN) = 1
END SUB
EXTERNAL SUB LCOPY(A(), B()) !'ÃÍ¥³¥Ô¡¼
MAT A=B
END SUB
EXTERNAL SUB LADD(A(), B(), C()) !'¿ÇÜĹƱ»Î¤Î²Ã»» C=A+B
LET SIGNA = A(SIGN)
LET SIGNB = B(SIGN)
IF SIGNA = 1 AND SIGNB = -1 THEN
LET B(SIGN) = 1
CALL LSUB (A, B, C)
LET B(SIGN) = -1
EXIT SUB
ELSEIF SIGNA = -1 AND SIGNB = 1 THEN
LET A(SIGN) = 1
CALL LSUB (B, A, C)
LET A(SIGN) = -1
EXIT SUB
END IF
MAT C=A+B
FOR I = KETA TO -BIAS + 1 STEP -1
IF C(I) >= 10000 THEN
LET C(I) = C(I) - 10000
LET C(I - 1) = C(I - 1) + 1
END IF
NEXT I
IF C(-BIAS) >= 10000 THEN
PRINT "OVER FLOW in LADD"
STOP
END IF
IF SIGNA = -1 AND SIGNB = -1 THEN LET C(SIGN) = -1 ELSE LET C(SIGN) = 1
END SUB
EXTERNAL SUB LADD2(A(),B()) !'¿ÇÜĹƱ»Î¤Î²Ã»» A=A+B
DIM C(-BIAS-1 TO KETA)
CALL LADD(A,B,C)
CALL LCOPY(A,C)
END SUB
EXTERNAL SUB LSUB (A(), B(), C())!'¿ÇÜĹƱ»Î¤Î¸º»» C=A-B
LET SIGNA = A(SIGN)
LET SIGNB = B(SIGN)
LET A(SIGN) = 1
LET B(SIGN) = 1
IF SIGNA * SIGNB = -1 THEN
CALL LADD (A, B, C)
LET C(SIGN) = SIGNA
LET A(SIGN) = SIGNA
LET B(SIGN) = SIGNB
EXIT SUB
END IF
LET GR = GREAT(A, B)
IF SIGNA = 1 AND SIGNB = 1 THEN
IF GR<>0 THEN
MAT C=A-B
LET C(SIGN) = 1
ELSE
MAT C=B-A
LET C(SIGN) = -1
END IF
ELSE
IF GR<>0 THEN
MAT C=B-A
LET C(SIGN) = 1
ELSE
MAT C=A-B
LET C(SIGN) = -1
END IF
END IF
FOR I = KETA TO -BIAS + 1 STEP -1
IF C(I) < 0 THEN
LET C(I) = C(I) + 10000
LET C(I - 1) = C(I - 1) - 1
END IF
NEXT I
LET A(SIGN) = SIGNA
LET B(SIGN) = SIGNB
END SUB
EXTERNAL SUB LSUB2(A(),B()) !'¿ÇÜĹƱ»Î¤Î¸º»» A=A-B
DIM C(-BIAS-1 TO KETA)
CALL LSUB(A,B,C)
CALL LCOPY(A,C)
END SUB
EXTERNAL SUB SDIV (A(), XA) !'³ä¤ê»» ¿ÇÜĹ¿ôA = ¿ÇÜĹ¿ôA / À°¿ôXA (1E+10ÄøÅÙ¤Þ¤Ç)
IF XA=0 THEN
PRINT "ERROR in SDIV"
STOP
END IF
LET SIGNA = A(SIGN)
LET SG = SGN(XA)
LET XX = ABS(XA)
FOR I = -BIAS TO KETA - 1
LET R = A(I) - INT(A(I) / XX) * XX
LET A(I) = INT(A(I) / XX)
LET A(I + 1) = A(I + 1) + R * 10000
NEXT I
LET A(KETA) = INT(A(KETA) / XX)
LET A(SIGN) = SIGNA * SG
END SUB
EXTERNAL SUB SMUL (A(), XA)!'³Ý¤±»» ¿ÇÜĹ¿ôA = ¿ÇÜĹ¿ôA * À°¿ôXA (1E+10ÄøÅÙ¤Þ¤Ç)
LET SIGNA = A(SIGN)
IF XA >= 0 THEN LET SG=1 ELSE LET SG=-1
LET XX = ABS(XA)
MAT A=(XX)*A
FOR I = KETA TO -BIAS + 1 STEP -1
IF A(I) >= 10000 THEN
LET R = INT(A(I) / 10000)
LET A(I) = A(I) - 10000 * R
LET A(I - 1) = A(I - 1) + R
END IF
NEXT I
IF A(-BIAS) >= 10000 THEN
PRINT "OVER FLOW in SMUL"
STOP
END IF
LET A(SIGN) = SIGNA * SG
END SUB
PUBLIC NUMERIC KETA,BIAS,EPS
INPUT PROMPT "·å¿ô=":KETA
LET KETA=INT(KETA/4)
LET EPS=2
LET BIAS=0
LET KETA=KETA+EPS
OPTION BASE 0
DIM S(KETA),A(KETA),B(KETA),C(KETA),AA(KETA),BB(KETA),CC(KETA),M(KETA)
LET N = 1
LET A(0)=3
LET B(0)=5
LET C(0)=7
FOR I = 0 TO KETA - 1
LET R = A(I) - INT(A(I) / 161) * 161
LET A(I) = INT(A(I) / 161)
LET A(I + 1) = A(I + 1) + R * 10000
LET R = B(I) - INT(B(I) / 49) * 49
LET B(I) = INT(B(I) / 49)
LET B(I + 1) = B(I + 1) + R * 10000
LET R = C(I) - INT(C(I) / 31) * 31
LET C(I) = INT(C(I) / 31)
LET C(I + 1) = C(I + 1) + R * 10000
NEXT I
LET A(KETA) = INT(A(KETA) / 161)
LET B(KETA) = INT(B(KETA) / 49)
LET C(KETA) = INT(C(KETA) / 31)
MAT S=S+A
MAT S=S+B
MAT S=S+C
FOR I = KETA TO 0 STEP -1
IF S(I) >= 10000 THEN
LET R = INT(S(I) / 10000)
LET S(I)=S(I)-R*10000
LET S(I - 1) = S(I - 1) + R
END IF
NEXT I
DO
FOR I = 0 TO KETA - 1
LET R = A(I) - INT(A(I) / 25921) * 25921
LET A(I) = INT(A(I) / 25921)
LET A(I + 1) = A(I + 1) + R * 10000
LET R = B(I) - INT(B(I) / 2401) * 2401
LET B(I) = INT(B(I) / 2401)
LET B(I + 1) = B(I + 1) + R * 10000
LET R = C(I) - INT(C(I) / 961) * 961
LET C(I) = INT(C(I) / 961)
LET C(I + 1) = C(I + 1) + R * 10000
NEXT I
LET A(KETA) = INT(A(KETA) / 25921)
LET B(KETA) = INT(B(KETA) / 2401)
LET C(KETA) = INT(C(KETA) / 961)
MAT AA=A
MAT BB=B
MAT CC=C
LET N=N+2
FOR I = 0 TO KETA - 1
LET R = AA(I) - INT(AA(I) / N) * N
LET AA(I) = INT(AA(I) / N)
LET AA(I + 1) = AA(I + 1) + R * 10000
LET R = BB(I) - INT(BB(I) / N) * N
LET BB(I) = INT(BB(I) / N)
LET BB(I + 1) = BB(I + 1) + R * 10000
LET R = CC(I) - INT(CC(I) / N) * N
LET CC(I) = INT(CC(I) / N)
LET CC(I + 1) = CC(I + 1) + R * 10000
NEXT I
LET AA(KETA) = INT(AA(KETA) / N)
LET BB(KETA) = INT(BB(KETA) / N)
LET CC(KETA) = INT(CC(KETA) / N)
MAT S=S+AA
MAT S=S+BB
MAT S=S+CC
FOR I = KETA TO 0 STEP -1
IF S(I) >= 10000 THEN
LET R = INT(S(I) / 10000)
LET S(I)=S(I)-R*10000
LET S(I - 1) = S(I - 1) + R
END IF
NEXT I
FOR J = 0 TO KETA
IF S(J)<>M(J) THEN
MAT M = S
LET K=J
EXIT FOR
END IF
NEXT J
LOOP WHILE J<=KETA-EPS
MAT S=2*S
FOR I = KETA TO 0 STEP -1
IF S(I) >= 10000 THEN
LET S(I) = S(I) - 10000
LET S(I - 1) = S(I - 1) + 1
END IF
NEXT I
CALL WRITEDATA(S,"")
END
EXTERNAL SUB WRITEDATA(X(),Z$)
IF Z$="" THEN OPEN #1:TextWindow1 ELSE OPEN #1:NAME Z$
ERASE #1
FOR KK=-BIAS TO KETA
IF X(KK)<>0 THEN EXIT FOR
NEXT KK
PRINT #1:"SUB LN2(X())"
PRINT #1:"CALL LCLR(X)"
PRINT #1:"LET X(SIGN)=1"
PRINT #1:"FOR I=";STR$(KK);" TO KETA"
PRINT #1:"READ IF MISSING THEN EXIT FOR:X(I)"
PRINT #1:"NEXT"
PRINT #1:"DATA ";
FOR I=KK TO KETA-EPS-1
LET K=K+1
IF MOD(K,25)=0 THEN
PRINT #1:RIGHT$("000"&STR$(X(I)),4)
PRINT #1:"DATA ";
ELSE
PRINT #1:RIGHT$("000"&STR$(X(I)),4);
IF I<>0 THEN PRINT #1:",";
END IF
IF -BIAS<=0 AND I=0 THEN
PRINT #1
PRINT #1:"DATA ";
LET K=0
END IF
NEXT I
PRINT #1:RIGHT$("000"&STR$(X(KETA-EPS)),4)
PRINT #1:"END SUB"
CLOSE #1
END SUB
PUBLIC NUMERIC BIAS, KETA, SIGN, EPS
LET EPS=12
LET N=2^9-EPS
LET BIAS = 0
LET KETA =-BIAS+N+EPS
LET SIGN = -BIAS - 1
DIM X(-BIAS - 1 TO KETA)
CALL LLOGPI(X)
CALL DISPLAY2(X)
END
EXTERNAL SUB LLOGPI(X())
DIM L(-BIAS - 1 TO KETA)
DIM A(-BIAS - 1 TO KETA), B(-BIAS - 1 TO KETA)
DIM S(-BIAS - 1 TO KETA), C(-BIAS - 1 TO KETA)
CALL PI(L)
CALL SDIV(L,9*31*14699) !'1710541690073718870111737129379 ¤Ç³ä¤ë
CALL SDIV(L,304439)
CALL SDIV(L,49368533)
CALL SDIV2(L,27751800277)
CALL SMUL(L,101*1657) !' 544482330679994391053312457583 Çܤ¹¤ë
CALL SMUL(L,3580259)
CALL SMUL(L,5392007)
CALL SMUL2(L,168529144463)
CALL LCLR(X)
LET X(0)=1
CALL LSUB2(X, L)
CALL LCOPY(B, X)
CALL LCOPY(S, X)
LET NN = 2
DO
CALL LMUL2(B, X)
CALL LCOPY(C, B)
CALL SDIV(C, NN)
LET NN = NN + 1
CALL LADD2(S, C)
LOOP UNTIL ZERO(B)<>0
LET S(SIGN)=-1
CALL LN1710541690073718870111737129379(L)
CALL LADD2(S,L)
CALL LN544482330679994391053312457583(L)
CALL LSUB(S,L,X)
END SUB
EXTERNAL SUB SMUL2(X(),XA) !'¿ÇÜĹ¿ôX = ¿ÇÜĹ¿ôX * À°¿ôXA (1E+11¡Á1E+14ÄøÅÙ¤Þ¤Ç)
DIM A(-BIAS*4 TO KETA*4+3) !'(´ð¿ô10000 ¢ª ´ð¿ô10 ¤ËÊÑ´¹¤·¤Æ·×»») ÀºÅÙÍî¤ÁÂкö
LET SIGNA = X(SIGN)
IF XA >= 0 THEN LET SG=1 ELSE LET SG=-1
LET XX = ABS(XA)
FOR I=-BIAS TO KETA
LET A(I*4)=MOD(INT(X(I)/1000),10)
LET A(I*4+1)=MOD(INT(X(I)/100),10)
LET A(I*4+2)=MOD(INT(X(I)/10),10)
LET A(I*4+3)=MOD(X(I),10)
NEXT I
MAT A=(XX)*A
FOR I=KETA*4 TO -BIAS*4+1 STEP -1
IF A(I) >= 10 THEN
LET R = INT(A(I) / 10)
LET A(I) = MOD(A(I),10)
LET A(I - 1) = A(I - 1) + R
END IF
NEXT I
IF A(-BIAS*4) >= 10 THEN
PRINT "OVER FLOW in SMUL2"
STOP
END IF
FOR I=-BIAS TO KETA-1
LET X(I)=A(I*4)*1000+A(I*4+1)*100+A(I*4+2)*10+A(I*4+3)
NEXT I
LET X(SIGN)= SIGNA * SG
END SUB
EXTERNAL SUB SDIV2(X(),XA) !'¿ÇÜĹ¿ôX = ¿ÇÜĹ¿ôX / À°¿ôXA (1E+11¡Á1E+14ÄøÅÙ¤Þ¤Ç)
DIM A(-BIAS*4 TO KETA*4+3) !'(´ð¿ô10000 ¢ª ´ð¿ô10 ¤ËÊÑ´¹¤·¤Æ·×»») ÀºÅÙÍî¤ÁÂкö
IF XA=0 THEN
PRINT "ERROR in SDIV2"
STOP
END IF
LET SIGNA = X(SIGN)
LET SG=SGN(XA)
LET XX = ABS(XA)
FOR I=-BIAS TO KETA
LET A(I*4)=MOD(INT(X(I)/1000),10)
LET A(I*4+1)=MOD(INT(X(I)/100),10)
LET A(I*4+2)=MOD(INT(X(I)/10),10)
LET A(I*4+3)=MOD(X(I),10)
NEXT I
FOR I=-BIAS*4 TO KETA*4-1
LET R = A(I) - INT(A(I) / XX) * XX
LET A(I) = INT(A(I) / XX)
LET A(I + 1) = A(I + 1) + R * 10
NEXT I
LET A(KETA*4)=INT(A(KETA*4)/XX)
FOR I=-BIAS TO KETA-1
LET X(I)=A(I*4)*1000+A(I*4+1)*100+A(I*4+2)*10+A(I*4+3)
NEXT I
LET X(SIGN)= SIGNA * SG
END SUB
EXTERNAL SUB LMUL(A(),B(),C())!'¿ÇÜĹƱ»Î¤Î¾è»» C=A*B
LET N=(KETA+BIAS)*2
IF INT(LOG2(N))<>LOG2(N) THEN
PRINT "ERROR in LMUL"
STOP
END IF
OPTION BASE 0
DIM AA(N*2),BB(N*2),CC(N*2)
FOR I=0 TO N/2-1
LET AA(2*I)=A(-BIAS+I)
LET BB(2*I)=B(-BIAS+I)
NEXT I
CALL CDFT(2*N, COS(PI/N), SIN(PI/N), AA)
CALL CDFT(2*N, COS(PI/N), SIN(PI/N), BB)
FOR I = 0 TO N-1
LET CC(2*I) = AA(2*I) * BB(2*I) - AA(2*I+1) * BB(2*I+1)
LET CC(2*I+1) = AA(2*I) * BB(2*I+1) + BB(2*I) * AA(2*I+1)
NEXT I
CALL CDFT(2*N, COS(PI/N), -SIN(PI/N), CC)
FOR I=0 TO N/2-1
IF -2*BIAS+I>=-BIAS AND -2*BIAS+I<=KETA THEN
LET C(-2*BIAS+I)=INT(CC(2*I)/N+.5)
END IF
NEXT I
FOR I=KETA TO -BIAS STEP -1
IF C(I) >=10000 THEN
LET R = INT(C(I) / 10000)
LET C(I) = C(I) - R * 10000
LET C(I - 1) = C(I - 1) + R
ELSEIF C(I)<0 THEN
LET C(I)=C(I)+10000
LET C(I-1)=C(I-1)-1
END IF
NEXT I
LET C(SIGN)=A(SIGN)*B(SIGN)
END SUB
EXTERNAL SUB LMUL2 (A(), B()) !'¿ÇÜĹƱ»Î¤Î¾è»» A=A*B
DIM C(-BIAS-1 TO KETA)
CALL LMUL(A,B,C)
CALL LCOPY(A,C)
END SUB
EXTERNAL SUB CDFT(N, WR, WI, A()) !'¥Í¥Ã¥È¾å¤«¤éÆþ¼ê¤·¤¿(¢¨¸¶ÈǤÏFORTRAN)
LET WMR = WR
LET WMI = WI
LET M = N
DO WHILE M > 4
LET L = M / 2
LET WKR = 1
LET WKI = 0
LET WDR = 1 - 2 * WMI * WMI
LET WDI = 2 * WMI * WMR
LET SS = 2 * WDI
LET WMR = WDR
LET WMI = WDI
FOR J = 0 TO N - M STEP M
LET I = J + L
LET XR = A(J) - A(I)
LET XI = A(J + 1) - A(I + 1)
LET A(J) = A(J) + A(I)
LET A(J + 1) = A(J + 1) + A(I + 1)
LET A(I) = XR
LET A(I + 1) = XI
LET XR = A(J + 2) - A(I + 2)
LET XI = A(J + 3) - A(I + 3)
LET A(J + 2) = A(J + 2) + A(I + 2)
LET A(J + 3) = A(J + 3) + A(I + 3)
LET A(I + 2) = WDR * XR - WDI * XI
LET A(I + 3) = WDR * XI + WDI * XR
NEXT J
FOR K = 4 TO L - 4 STEP 4
LET WKR = WKR - SS * WDI
LET WKI = WKI + SS * WDR
LET WDR = WDR - SS * WKI
LET WDI = WDI + SS * WKR
FOR J = K TO N - M + K STEP M
LET I = J + L
LET XR = A(J) - A(I)
LET XI = A(J + 1) - A(I + 1)
LET A(J) = A(J) + A(I)
LET A(J + 1) = A(J + 1) + A(I + 1)
LET A(I) = WKR * XR - WKI * XI
LET A(I + 1) = WKR * XI + WKI * XR
LET XR = A(J + 2) - A(I + 2)
LET XI = A(J + 3) - A(I + 3)
LET A(J + 2) = A(J + 2) + A(I + 2)
LET A(J + 3) = A(J + 3) + A(I + 3)
LET A(I + 2) = WDR * XR - WDI * XI
LET A(I + 3) = WDR * XI + WDI * XR
NEXT J
NEXT K
LET M = L
LOOP
IF M > 2 THEN
FOR J = 0 TO N - 4 STEP 4
LET XR = A(J) - A(J + 2)
LET XI = A(J + 1) - A(J + 3)
LET A(J) = A(J) + A(J + 2)
LET A(J + 1) = A(J + 1) + A(J + 3)
LET A(J + 2) = XR
LET A(J + 3) = XI
NEXT J
END IF
IF N > 4 THEN CALL BITRV2(N, A)
END SUB
EXTERNAL SUB BITRV2(N, A())
LET M = N / 4
LET M2 = 2 * M
LET N2 = N - 2
LET K = 0
FOR J = 0 TO M2 - 4 STEP 4
IF J < K THEN
LET XR = A(J)
LET XI = A(J + 1)
LET A(J) = A(K)
LET A(J + 1) = A(K + 1)
LET A(K) = XR
LET A(K + 1) = XI
ELSEIF J > K THEN
LET J1 = N2 - J
LET K1 = N2 - K
LET XR = A(J1)
LET XI = A(J1 + 1)
LET A(J1) = A(K1)
LET A(J1 + 1) = A(K1 + 1)
LET A(K1) = XR
LET A(K1 + 1) = XI
END IF
LET K1 = M2 + K
LET XR = A(J + 2)
LET XI = A(J + 3)
LET A(J + 2) = A(K1)
LET A(J + 3) = A(K1 + 1)
LET A(K1) = XR
LET A(K1 + 1) = XI
LET L = M
DO WHILE K >= L
LET K = K - L
LET L = L / 2
LOOP
LET K = K + L
NEXT J
END SUB
EXTERNAL SUB PI(X()) !'¦ÐÃÍ
CALL LCLR (X)
LET X(SIGN)=1
FOR I=0 TO KETA
READ IF MISSING THEN EXIT FOR:X(I)
NEXT I
DATA 0003
DATA
1415,9265,3589,7932,3846,2643,3832,7950,2884,1971,6939,9375,1058,2097,4944,5923,0781,6406,2862,0899,8628,0348,2534,2117,0679
DATA
8214,8086,5132,8230,6647,0938,4460,9550,5822,3172,5359,4081,2848,1117,4502,8410,2701,9385,2110,5559,6446,2294,8954,9303,8196
DATA
4428,8109,7566,5933,4461,2847,5648,2337,8678,3165,2712,0190,9145,6485,6692,3460,3486,1045,4326,6482,1339,3607,2602,4914,1273
DATA
7245,8700,6606,3155,8817,4881,5209,2096,2829,2540,9171,5364,3678,9259,0360,0113,3053,0548,8204,6652,1384,1469,5194,1511,6094
DATA
3305,7270,3657,5959,1953,0921,8611,7381,9326,1179,3105,1185,4807,4462,3799,6274,9567,3518,8575,2724,8912,2793,8183,0119,4912
DATA
9833,6733,6244,0656,6430,8602,1394,9463,9522,4737,1907,0217,9860,9437,0277,0539,2171,7629,3176,7523,8467,4818,4676,6940,5132
DATA
0005,6812,7145,2635,6082,7785,7713,4275,7789,6091,7363,7178,7214,6844,0901,2249,5343,0146,5495,8537,1050,7922,7968,9258,9235
DATA
4201,9956,1121,2902,1960,8640,3441,8159,8136,2977,4771,3099,6051,8707,2113,4999,9998,3729,7804,9951,0597,3173,2816,0963,1859
DATA
5024,4594,5534,6908,3026,4252,2308,2533,4468,5035,2619,3118,8171,0100,0313,7838,7528,8658,7533,2083,8142,0617,1776,6914,7303
DATA
5982,5349,0428,7554,6873,1159,5628,6388,2353,7875,9375,1957,7818,5778,0532,1712,2680,6613,0019,2787,6611,1959,0921,6420,1989
DATA
3809,5257,2010,6548,5863,2788,6593,6153,3818,2796,8230,3019,5203,5301,8529,6899,5773,6225,9941,3891,2497,2177,5283,4791,3151
DATA
5574,8572,4245,4150,6959,5082,9533,1168,6172,7855,8890,7509,8381,7546,3746,4939,3192,5506,0400,9277,0167,1139,0098,4882,4012
DATA
8583,6160,3563,7076,6010,4710,1819,4295,5596,1989,4676,7837,4494,4825,5379,7747,2684,7104,0475,3464,6208,0466,8425,9069,4912
DATA
9331,3677,0289,8915,2104,7521,6205,6966,0240,5803,8150,1935,1125,3382,4300,3558,7640,2474,9647,3263,9141,9927,2604,2699,2279
DATA
6782,3547,8163,6009,3417,2164,1219,9245,8631,5030,2861,8297,4555,7067,4983,8505,4945,8858,6926,9956,9092,7210,7975,0930,2955
DATA
3211,6534,4987,2027,5596,0236,4806,6549,9119,8818,3479,7753,5663,6980,7426,5425,2786,2551,8184,1757,4672,8909,7777,2793,8000
DATA
8164,7060,0161,4524,9192,1732,1721,4772,3501,4144,1973,5685,4816,1361,1573,5255,2133,4757,4184,9468,4385,2332,3907,3941,4333
DATA
4547,7624,1686,2518,9835,6948,5562,0992,1922,2184,2725,5025,4256,8876,7179,0494,6016,5346,6804,9886,2723,2791,7860,8578,4383
DATA
8279,6797,6681,4541,0095,3883,7863,6095,0680,0642,2512,5205,1173,9298,4896,0841,2848,8626,9456,0424,1965,2850,2221,0661,1863
DATA
0674,4278,6220,3919,4945,0471,2371,3786,9609,5636,4371,9172,8746,7764,6575,7396,2413,8908,6583,2645,9958,1339,0478,0275,9009
DATA 9465,7640,7895,1269,4683,9835,2595,7098,2582,2620,5224,8940
END SUB
EXTERNAL SUB LN1710541690073718870111737129379(X()) !'LOG(1710..)ÃÍ
CALL LCLR(X)
LET X(SIGN)=1
FOR I=0 TO KETA
READ IF MISSING THEN EXIT FOR:X(I)
NEXT I
DATA 0069
DATA
6143,6288,7993,3268,3004,4228,2256,8485,2026,6785,3596,6394,4004,2459,4994,5470,1366,5214,8581,6415,4697,3145,7866,1523,7272
DATA
6551,2059,0127,0534,7351,7820,4920,0008,7989,9541,7800,2163,7623,0895,4887,3922,8357,3520,5004,0375,5683,9209,4332,0242,9540
DATA
1748,4435,3241,8232,0917,6048,6351,8267,6655,4103,1920,3713,6534,2808,6848,0068,3923,2800,1886,4684,2394,0286,5595,7822,8870
DATA
6824,4083,5434,5674,3002,0302,6430,7887,0940,1081,9799,5193,2835,3565,5690,4021,5682,1679,9587,2726,5741,7738,9966,8303,9374
DATA
4065,5626,7370,2317,3186,2152,1129,2984,3621,1141,6888,7106,2708,7294,1105,4881,3419,1360,3002,9792,2275,7776,7209,3100,7189
DATA
1333,2926,5906,5310,6574,2333,0024,4444,6043,7221,5935,4199,0820,3015,5200,1473,4002,4862,2284,7807,2731,8261,8953,2953,7309
DATA
4162,4615,8900,1280,1186,1445,3416,9135,4404,4277,0805,7623,1006,4866,6480,4750,1673,5797,3590,6210,4828,8466,8064,0621,5369
DATA
6822,3112,8752,9922,5756,4306,5244,5723,7782,5053,2215,5848,6850,0720,0010,0839,6060,6790,9162,7960,6519,9616,7812,3819,6481
DATA
2850,4009,5322,6067,3979,0496,8839,2466,5255,0930,4737,8771,8972,6183,6781,6485,6742,6847,7569,0628,3272,4958,9055,0595,1667
DATA
0318,1311,7655,2636,5449,8892,8994,6549,8185,5605,1410,8418,3957,3941,9585,7859,8354,6284,4894,3324,7101,4235,7355,6297,7705
DATA
6284,7948,3668,3827,3890,3916,7911,8682,2761,6156,8577,8088,8066,9387,2851,5278,4084,2809,0879,0882,6939,4694,4014,9549,7450
DATA
2911,5763,0278,3692,1766,1804,8124,9781,4074,8058,6307,1025,2785,0760,5599,0083,4081,9099,0502,6793,1794,6341,6502,0176,2868
DATA
3796,2139,9878,6835,7170,1164,2205,6497,0107,8877,3771,7488,8657,5263,9761,2416,6278,3016,1690,0953,1383,8181,7952,3541,1635
DATA
6891,5224,4409,2332,4874,2319,4524,2884,0889,5022,8222,5650,3677,3971,7593,6214,1500,2361,0686,4206,4017,9737,8034,3987,7461
DATA
5150,7437,9961,5876,6881,2221,9103,9820,1354,6600,2760,3220,1344,0667,5700,0559,0702,6840,8532,2596,9193,2134,9548,5155,8877
DATA
1115,9327,4668,8319,5471,2802,0874,9640,1131,7970,8168,2428,1598,3983,6017,5960,3281,6942,4686,9574,9764,9433,1216,4959,2387
DATA
0873,8907,8785,5093,6238,0367,4603,0384,3624,6755,5657,2459,9473,2847,7735,8517,5154,0299,6744,3440,0577,4508,6886,3276,1136
DATA
3026,8720,1951,3001,5676,9739,1394,0643,7786,6988,0521,2185,7078,9937,0618,4466,8235,0108,8657,3294,3409,0176,9410,4535,3487
DATA
5923,4566,3163,5408,2042,0034,7213,0857,1778,0402,9447,8452,8732,6232,4880,1913,2182,3249,5532,6094,1509,8743,6779,9084,9870
DATA
0148,8381,3012,8627,2066,3865,1370,4664,5664,9339,4367,0190,7057,6215,5163,9757,6009,6007,7540,5813,9957,0761,4465,5132,0577
DATA 5503,8417,6557,8706,8939,7814,1500,5247,4757,4949,9209,4162
END SUB
EXTERNAL SUB LN544482330679994391053312457583(X()) !'LOG(5444..)ÃÍ
CALL LCLR(X)
LET X(SIGN)=1
FOR I=0 TO KETA
READ IF MISSING THEN EXIT FOR:X(I)
NEXT I
DATA 0068
DATA
4696,3300,2143,9266,5590,0800,8743,3179,3315,0312,4115,3479,0888,5308,1371,0786,7772,6582,8354,8087,7911,8425,1658,1624,6863
DATA
3534,2720,9432,7548,7948,6284,7447,1357,2875,4696,1898,3726,1025,5558,4562,0907,4477,6791,4979,6390,9355,8684,7181,2383,6067
DATA
5125,9038,3164,5872,4149,1463,9290,8100,8221,3858,4661,7368,8894,4392,1782,5529,1379,0706,7263,6717,7094,2864,3556,3900,7575
DATA
8220,5281,5426,2279,7293,8843,9725,1183,2375,0876,2708,1484,0473,9670,8817,3223,4819,0068,2413,2727,7063,0621,1175,4750,7107
DATA
8671,3441,3378,9146,9346,1923,8237,0526,7108,5413,6817,1946,4759,6110,2330,5046,3222,6584,6590,6347,9478,9162,1229,8258,0639
DATA
8629,0999,7506,3639,3766,9619,4748,6069,6562,5828,2302,4778,3079,2466,1935,4340,5305,9867,9470,7594,5310,3809,3799,2927,1647
DATA
2356,9062,6748,9596,1245,0147,5975,5100,6274,8333,6949,6146,2909,4481,6231,2366,8112,4857,0275,2529,1010,3037,7042,6637,0392
DATA
1670,0491,9722,4984,9411,3815,8869,2731,5703,6430,4132,8603,8424,8368,8011,9123,4089,8308,1853,8980,8362,2095,2457,1928,3638
DATA
0053,3991,4538,1624,6079,4415,8152,2109,6785,7592,9725,2195,0650,0526,5590,0422,3146,3046,8647,5876,9130,4732,3389,1245,8068
DATA
7812,3293,5439,3929,1890,9399,6703,8878,7077,5335,6941,7431,1782,2323,8457,0834,4553,9586,3123,6397,5711,0712,1356,5910,7625
DATA
2193,7131,0681,5285,6609,1095,4149,6754,7763,2836,8796,8730,4951,2823,6551,9299,6014,9348,6341,1187,0646,7366,9790,3242,0076
DATA
3159,2614,7305,1479,3803,0883,1726,8138,1385,3562,1576,6493,8245,0199,7851,4583,9672,9911,8496,3168,7333,7765,0503,4451,0920
DATA
5090,5214,6787,1314,6772,6862,3736,8572,0251,7508,8096,1615,0470,5139,3677,8073,5561,0597,8884,4253,9075,0348,7834,3251,6913
DATA
6549,9352,6478,6587,3687,6446,5803,7343,1607,6931,6148,2364,8107,6286,4138,6620,4422,4124,9848,5744,8327,3790,8854,9012,5488
DATA
6930,5446,1559,2103,7235,1105,4337,1632,8662,1702,8001,9460,1977,8871,6694,9328,1262,7307,0409,3747,7022,2234,8243,0766,1057
DATA
1794,9925,2660,2292,2678,0591,1757,8530,6030,0003,8275,0990,6180,5366,9308,0990,1612,3368,9265,3857,0729,5854,4739,4278,6728
DATA
2111,2446,8161,9364,0415,6814,3644,1779,3609,4265,9090,3322,2336,7923,4096,4595,1538,1568,3121,3374,7747,7340,2591,1985,8297
DATA
1375,4564,3882,8472,3644,4193,1371,2433,7491,7818,1991,7233,1335,2034,1296,1177,3339,7135,6549,2440,4227,1453,0204,3370,3408
DATA
9449,0546,0281,3840,9872,7548,2470,7503,6138,4063,2497,2268,8601,9381,1855,0714,6065,2571,9613,8541,6472,6325,5532,3632,6764
DATA
0684,0804,6469,2615,3651,3647,2317,6321,2200,3895,4491,6134,5365,5560,5641,2651,0168,7531,0092,4478,8313,3640,3413,7462,9541
DATA 1403,9443,4183,7689,8013,2877,3469,9226,6078,9523,0380,9531
END SUB
PUBLIC NUMERIC KETA,EPS,SIGN
INPUT PROMPT "·å¿ô=":KETA
LET KETA=INT(KETA/4)
LET EPS=2
LET BIAS=0
LET KETA=KETA+EPS
LET SIGN=-BIAS-1
DIM A(-BIAS-1 TO KETA),S(-BIAS-1 TO KETA),T(-BIAS-1 TO KETA)
LET A(0)=1
LET S(0)=1
LET N=1
DO
MAT A=(2*N-1)*A
FOR I = 0 TO KETA - 1
LET R = A(I) - INT(A(I)/16692642/N)*(16692642*N)
LET A(I) = INT(A(I) /16692642/N)
LET A(I + 1) = A(I + 1) + R * 10000
NEXT I
LET A(KETA) = INT(A(KETA)/16692642/N)
MAT S=S+A
FOR I = KETA TO 0 STEP -1
IF S(I) >= 10000 THEN
LET R = INT(S(I) / 10000)
LET S(I) = S(I) - R * 10000
LET S(I-1) = S(I-1) + R
END IF
NEXT I
LET FL=0
FOR I=0 TO KETA
IF S(I)<>T(I) THEN
LET T(I)=S(I)
LET FL=1
LET N=N+1
EXIT FOR
END IF
NEXT I
IF FL=0 THEN EXIT DO
LOOP
MAT S=6460*S
FOR I = KETA TO 0 STEP -1
IF S(I) >= 10000 THEN
LET R = INT(S(I) / 10000)
LET S(I) = S(I) - R * 10000
LET S(I-1) = S(I-1) + R
END IF
NEXT I
FOR I = 0 TO KETA - 1
LET R = S(I) - INT(S(I)/2889)*2889
LET S(I) = INT(S(I)/2889)
LET S(I + 1) = S(I + 1) + R * 10000
NEXT I
LET S(KETA) = INT(S(KETA)/2889)
LET S(0)=S(0)+1
FOR I = 0 TO KETA - 1
LET R = S(I) - INT(S(I)/2)*2
LET S(I) = INT(S(I)/2)
LET S(I + 1) = S(I + 1) + R * 10000
NEXT I
LET S(KETA) = INT(S(KETA)/2)
CALL DISPLAY(S)
END
EXTERNAL SUB DISPLAY(X())
FOR K=-BIAS TO 0
IF X(K)<>0 THEN EXIT FOR
NEXT K
IF K > 0 THEN LET K=0
IF X(SIGN) = -1 THEN PRINT "- ";
PRINT STR$(X(K));" ";
IF K=0 THEN PRINT "."
FOR I=K+1 TO KETA-EPS
LET L=L+1
PRINT RIGHT$("000"&STR$(X(I)),4);" ";
IF I=0 THEN
PRINT "."
LET L=0
END IF
IF MOD(L,25)=0 THEN PRINT
NEXT I
PRINT
END SUB
!¿Þ·Á¤È¥Ù¥¯¥È¥ëÊýÄø¼°¡Ê»°³Ñ·Á¤Î¿´¡Ë
!Ê¿Ì̤ÎÅÀ¤ò¡ÖÊ¿Ì̤Υ٥¯¥È¥ë¤È¤ß¤ë¡×¤È¡ÖÊ£ÁÇ¿ô¤È¤ß¤ë¡×¤È¹Í¤¨¤é¤ì¤ë
OPTION ARITHMETIC COMPLEX
DEF v(a,b)=COMPLEX(a,b) !Ê£ÁÇ¿ô¤ÎϺ¹¡¢¼Â¿ôÇܤη׻»¤òÂбþ¤µ¤»¤ë
DEF fnDOT(a,b)=( a*conj(b) + conj(a)*b ) / 2 !ÆâÀÑ¡¡a1*b1+a2*b2
!ÀäÂÐÃÍ¡¡¥Ù¥¯¥È¥ë |a|^2=a¡¦a¡¡¡¡Ê£ÁÇ¿ô |z|^2=z*conj(z)
DEF fnNormalize(a)=a/ABS(a) !Àµµ¬²½
!------------------------------ ¤³¤³¤Þ¤Ç¤¬¥µ¥Ö¥ë¡¼¥Á¥ó
SET WINDOW -8,8,-8,8 !ɽ¼¨Îΰè¤òÀßÄꤹ¤ë
DRAW grid !XYºÂɸ
ASK PIXEL SIZE (-8,-8; 8,8) w,h !²èÁü¤Î½Ä²£¤ÎÂ礤µ(¥É¥Ã¥Èñ°Ì)¤òÄ´¤Ù¤ë
LET cEps=0.1 !ÀºÅÙ¡¡¢¨Ä´À°¤¬É¬ÍפǤ¢¤ë
SET POINT STYLE 1 !ÅÀ¤Î·Á¾õ
!Îã¡¡»°³Ñ·ÁABC¤Î¿´
!¡¡¡¡¡¡C
!¡¡b ¡¿¡À a
!¡¡A ¨¡¨¡ B
!¡¡¡¡ c
LET OA=v(-4,-5)
LET OB=v(3,-4)
LET OC=v(4,6)
LET AB=OB-OA !ÊÕAB
LET BC=OC-OB !ÊÕBC
LET CA=OA-OC !ÊÕCA
PLOT LINES: Re(OA),Im(OA); Re(OB),Im(OB) !ÊÕAB¤òÉÁ¤¯
PLOT LINES: Re(OB),Im(OB); Re(OC),Im(OC) !ÊÕBC
PLOT LINES: Re(OC),Im(OC); Re(OA),Im(OA) !ÊÕCA
LET a=ABS(BC) !ÊÕBC¤ÎŤµ
LET b=ABS(CA) !ÊÕCA
LET c=ABS(AB) !ÊÕAB
LET t=(a+b+c)/2 !¥Ø¥í¥ó¤Î¸ø¼°¤è¤ê¡¢ÌÌÀÑS
LET S=SQR(t*(t-a)*(t-b)*(t-c))
!------------------------------
LET OI=(a*OA+b*OB+c*OC)/(a+b+c) !Æâ¿´¤Î°ÌÃÖ¥Ù¥¯¥È¥ë
SET AREA COLOR 4
DRAW disk WITH SCALE(0.2)*SHIFT(OI)
SET LINE COLOR 4
LET R=S/t !S=¢¤IAB+¢¤IBC+¢¤ICA=1/2*c*r+1/2*a*r+1/2*b*r=r*(a+b+c)/2¤è¤ê
DRAW circle WITH SCALE(R)*SHIFT(OI) !ÆâÀܱߤòÉÁ¤¯¡¡|z-¦Á|=r
CALL DrawLine4(OA,OB,OC)
SUB DrawLine4(OA,OB,OC) !¤¢ÜBAC¤òÆóÅùʬ¤¹¤ëÀþ
FOR t=0 TO 10 !t=[0,¡ç]¡¡¢¨ÈϰϤÏÄ´À°¤¬É¬ÍפǤ¢¤ë
LET wAB=OB-OA
LET wAC=OC-OA
LET OP=OA+(fnNormalize(wAB)+fnNormalize(wAC))*t !¤Ò¤··ÁAbDc¤ÎÂгÑÀþAD
PLOT LINES: Re(OP),Im(OP);
NEXT t
PLOT LINES
END SUB
CALL DrawLine4(OB,OC,OA)
CALL DrawLine4(OC,OA,OB)
!------------------------------
LET OG=(OA+OB+OC)/3 !½Å¿´¤Î°ÌÃÖ¥Ù¥¯¥È¥ë
SET AREA COLOR 2
DRAW disk WITH SCALE(0.2)*SHIFT(OG)
SET LINE COLOR 2
CALL DrawLine2(OA,OB,OC)
SUB DrawLine2(OA,OB,OC) !¢ÅÀA¤ÈÊÕBC¤ÎÃæÅÀ¤òÄ̤ëÀþ
FOR t=0 TO 10 !t=[0,¡ç]¡¡¢¨ÈϰϤÏÄ´À°¤¬É¬ÍפǤ¢¤ë
LET OP=OA+(OB+OC-2*OA)*t !Ê¿¹Ô»ÍÊÕ·ÁABDC¤ÎÂгÑÀþAD
PLOT LINES: Re(OP),Im(OP);
NEXT t
PLOT LINES
END SUB
CALL DrawLine2(OB,OC,OA)
CALL DrawLine2(OC,OA,OB)
!------------------------------
LET sin2A=2*S*(b^2+c^2-a^2)/(b*c)^2 !sin2A=2*cosA*sinA¡¢Í¾¸¹ÄêÍýcosA=(b^2+c^2-a^2)/(2*b*c)¡¢ÌÌÀÑS=1/2*b*c*sinA¤è¤ê
LET sin2B=2*S*(c^2+a^2-b^2)/(c*a)^2
LET sin2C=2*S*(a^2+b^2-c^2)/(a*b)^2
LET OQ=(sin2A*OA+sin2B*OB+sin2C*OC)/(sin2A+sin2B+sin2C) !³°¿´¤Î°ÌÃÖ¥Ù¥¯¥È¥ë
SET AREA COLOR 3
DRAW disk WITH SCALE(0.2)*SHIFT(OQ)
SET LINE COLOR 3
LET R=a*b*c/(4*S) !Àµ¸¹ÄêÍýa/sinA=b/sinB=c/sinC=2*R¤ÈÌÌÀÑS=1/2*b*c*sinA¤è¤ê
DRAW circle WITH SCALE(R)*SHIFT(OQ) !³°ÀܱߤòÉÁ¤¯
!------------------------------
LET tanA=2*S/(b^2+c^2-a^2) !tanA=sinA/cosA¤È;¸¹ÄêÍýcosA=(b^2+c^2-a^2)/(2*b*c)¤ÈÌÌÀÑS=1/2*b*c*sinA¤è¤ê
LET tanB=2*S/(c^2+a^2-b^2)
LET tanC=2*S/(a^2+b^2-c^2)
LET OH=(tanA*OA+tanB*OB+tanC*OC)/(tanA+tanB+tanC) !¿â¿´¤Î°ÌÃÖ¥Ù¥¯¥È¥ë
SET AREA COLOR 1
DRAW disk WITH SCALE(0.2)*SHIFT(OH)
FOR j=0 TO h !²èÌÌÁ´ÂΤòÁöºº¤¹¤ë
LET y=worldy(j) !¥É¥Ã¥È¤òxyºÂɸ¤ËÊÑ´¹¤¹¤ë
FOR i=0 TO w
LET x=worldx(i)
LET OP=v(x,y)
SET POINT COLOR 3 !³°¿´
IF ABS( fnDOT(OP-(OB+OC)/2,BC) )<cEps THEN PLOT POINTS: x,y !£ÊÕBC¤Î¿âľÆóÅùʬÀþ
IF ABS( fnDOT(OP-(OC+OA)/2,CA) )<cEps THEN PLOT POINTS: x,y
IF ABS( fnDOT(OP-(OA+OB)/2,AB) )<cEps THEN PLOT POINTS: x,y
SET POINT COLOR 1 !¿â¿´
IF ABS( fnDOT(OP-OA,BC) )<cEps THEN PLOT POINTS: x,y !¡ÅÀA¤«¤éÊÕBC¤Ø¤Î¿âÀþ¡¡AP¢ÝBC
IF ABS( fnDOT(OP-OB,CA) )<cEps THEN PLOT POINTS: x,y
IF ABS( fnDOT(OP-OC,AB) )<cEps THEN PLOT POINTS: x,y
NEXT i
NEXT j
END
LET t0=TIME
PUBLIC NUMERIC N !¥«¡¼¥É¤ÎËç¿ô
LET N=13
DIM c(N) !ºÇ½é¤Î¥Ñ¥¿¡¼¥ó¡¡¢¨
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13
MAT READ c
PUBLIC NUMERIC GOAL(100) !ºÇ½ª¤Î¥Ñ¥¿¡¼¥ó¡¡¢¨
MAT GOAL=ZER(N)
DATA -9,-8,-7,1,2,4,5,6,-3,10,11,12,13
MAT READ GOAL
PUBLIC NUMERIC LIMIT !¼ê¿ô¤Î¾å¸Â¡¡¢¨
LET LIMIT=10
DIM A(LIMIT) !Ëç¿ô
CALL backtrack(c,1,A)
PRINT "·×»»»þ´Ö=";TIME-t0
END
EXTERNAL SUB reverse(c(),P) !ÀèƬ¤«¤éPËç¤ò΢ÊÖ¤¹
FOR i=1 TO INT(P/2) !¸ò´¹
LET t=c(i)
LET c(i)=c(P-i+1)
LET c(P-i+1)=t
NEXT i
FOR i=1 TO P !ȿž
LET c(i)=-c(i)
NEXT i
END SUB
EXTERNAL SUB backtrack(c(),K,A()) !¥Ð¥Ã¥¯¥È¥é¥Ã¥¯Ë¡¤Ç¸¡¾Ú¤¹¤ë
IF K<=LIMIT THEN !¼ê¿ô¤Î¾å¸ÂÆâ¤Ê¤é
DIM x(N)
MAT x=c !save it
FOR i=1 TO N !Ëç¿ô¤òÊѤ¨¤ë
LET A(K)=i
CALL reverse(c,i) !ȿž
FOR j=1 TO N !ºÇ½ª¤Î¥Ñ¥¿¡¼¥ó¤«¤É¤¦¤«³Îǧ¤¹¤ë
IF c(j)<>GOAL(j) THEN EXIT FOR
NEXT j
IF j>N THEN !°ìÃפ·¤¿¤é
LET LIMIT=K-1 !¾å¸Â¤ò¶¹¤á¤ë¡¡¢¨ºÇ½é¤Ë¸«¤Ä¤«¤Ã¤¿¤â¤Î
PRINT K;"¼ê"
FOR j=1 TO K
PRINT A(j); !Ëç¿ô
NEXT j
PRINT
!!!MAT PRINT c; !debug
ELSE
CALL backtrack(c,K+1,A) !¼¡¤Ø
END IF
MAT c=x !restore it
NEXT i
END IF
END SUB
LET t0=TIME
PUBLIC NUMERIC N !¥«¡¼¥É¤ÎËç¿ô
LET N=13
DIM c(N) !ºÇ½é¤Î¥Ñ¥¿¡¼¥ó¡¡¢¨
DATA 1,2,3,4,5,6,7,8,9,10,11,12,13
MAT READ c
PUBLIC NUMERIC LIMIT !¼ê¿ô¤Î¾å¸Â¡¡¢¨
LET LIMIT=4
PUBLIC NUMERIC cMIN !ºÇ¾¯¼ê¿ô
LET cMIN=LIMIT+1
DIM A(LIMIT) !Ëç¿ô
CALL backtrack(c,0,A)
IF cMIN<=LIMIT THEN PRINT "ºÇ¾¯¼ê¿ô=";cMIN
PRINT "·×»»»þ´Ö=";TIME-t0
END
EXTERNAL SUB reverse(c(),P) !ÀèƬ¤«¤éPËç¤ò΢ÊÖ¤¹
FOR i=1 TO INT(P/2) !¸ò´¹
LET t=c(i)
LET c(i)=c(P-i+1)
LET c(P-i+1)=t
NEXT i
FOR i=1 TO P !ȿž
LET c(i)=-c(i)
NEXT i
END SUB
EXTERNAL SUB backtrack(c(),K,A()) !¥Ð¥Ã¥¯¥È¥é¥Ã¥¯Ë¡¤Ç¸¡¾Ú¤¹¤ë
LET s=0
FOR j=1 TO N !ɽ¤ÎËç¿ô¤ò³Îǧ¤¹¤ë
IF c(j)<0 THEN LET s=s+1
NEXT j
IF s=4 THEN !°ìÃפ·¤¿¤é
IF K<cMIN THEN LET cMIN=K !ºÇ¾¯¼ê¿ô¤òµÏ¿¤¹¤ë
PRINT K;"¼ê"
FOR j=1 TO K
PRINT A(j); !Ëç¿ôÎó
NEXT j
PRINT
MAT PRINT c; !ºÇ½ª¤Î¥Ñ¥¿¡¼¥ó
ELSE
IF K<LIMIT THEN !¼ê¿ô¤Î¾å¸ÂÆâ¤Ê¤é
DIM x(N)
MAT x=c !save it
FOR i=1 TO N !Ëç¿ô¤òÊѤ¨¤ë
IF K>=1 AND i=A(K) THEN !Ʊ¤¸¼ê¤¬Â³¤¯¾ì¹ç¤Ï̵¸ú¡ª
ELSE
LET A(K+1)=i
CALL reverse(c,i) !ȿž
CALL backtrack(c,K+1,A) !¼¡¤Ø
MAT c=x !restore it
END IF
NEXT i
END IF
END IF
END SUB
¿··Ç¼¨Èij«Àß
Åê¹Æ¼Ô¡§ÇòÀС¡ÏÂÉ× Åê¹ÆÆü¡§2008ǯ 7·î21Æü(·î)09»þ38ʬ46Éåᥤ¥ó¤Î·Ç¼¨ÈĤ¬ÉÔÄ´¤Î¤È¤¡¤¤³¤Á¤é¤ò¤´ÍøÍѤ¯¤À¤µ¤¤¡£
¤Ê¤ª¡¤ºÇÂç500¹Ô¤Þ¤Ç½ñ¤¹þ¤á¤ë¤³¤È¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤¬¡¤
¼Â¸³Åª¤Ë¤Ï251¹Ô¤Þ¤Ç¤·¤«½ñ¤¹þ¤á¤Ê¤¤¤è¤¦¤Ç¤¹¡£
Internet Explorer¤Ç¤â¥¤¥ó¥Ç¥ó¥È¤òÊÝ»ý¤·¤¿¤Þ¤Þɽ¼¨¤µ¤ì¤ë¤³¤È¡¤
Ʊ°ì¿Í¤Ë¤è¤ëϢ³½ñ¤¹þ¤ß¤Ëµ¬À©¤¬¤«¤«¤ë¤³¤È¡Ê¥¹¥Ñ¥àÂкö¡Ë
¤Ê¤É¡¤ÍøÅÀ¤â¿¤¤¤Î¤Ç¡¤¾ÍèŪ¤Ë¤ÏËܳÊŪ¤Ê°Üž¤â¤¢¤ê¤¨¤Þ¤¹¡£