IF EXIST sok.bas n88basic /e:gpib って書いてあるバッチファイルtest.batを外部コマンド起動させるプログラム class Gaibu { public static void main(String args[]) { try { Runtime.getRuntime().exec("A:\\B\\test.bat"); }catch (Exception ex) { }
} } をjavacでコンパイルしてjavaで起動させたのですが NEC N-88 BASIC(86) version 6.0 Copyright (C) 1984,88 by NEC Corporation 432396 Bytes free Ok って文字が出たあと何も文字が打ち込めなくなってしまいます。 バッチファイルを直接ダブルクリックすれば普通に文字が打ち込めるのですが。 どうすればJavaプログラム上でn88basicをまともに起動できるのか教えてください。
10 go to 20 20 go to 30 30 go to 40 40 go to 50 50 go to 60 60 go to 70 70 go to 80 80 go to 90 90 go to 100 100 go to 110 110 go to 120 120 go to 130 130 go to 160 140 go to 170 150 go to 140 160 go to 150 170 go to 200 180 go to 190 190 go to 210 200 go to 180 210 go to 220 220 go to 230 230 go to 240 240 go to 250 250 go to 260 260 go to 270 270 go to 280 280 go to 290 290 go to 300 300 go to 310 310 go to 320 320 go to 330 330 go to 340 340 go to 350 350 go to 360 360 go to 10 run
100 INPUT "P="; P 110 FOR A = 1 TO P-1 120 (ウ) 130 FOR I = 1 TO P-1 140 IF (エ) THEN PRINT "f(";A;")= ";I:GOTO 180 150 B = A*B-P*INT(A*B/P) 160 NEXT I 170 PRINT "f(";A;")= 0" 180 NEXT A 190 END
>>166 補足すると、禁止されているのは「他のFOR〜NEXTループに飛びこむ」事ですね。 あと、昔のゲームのプログラム見ると FOR I=1 TO 10 .... IF I=5 THEN NEXT ... IF I=8 THEN NEXT NEXT なんていうコードも通っていたんだが、この頃の処理系ではダメと思った。 (今のCでいうところのcontinueな)
210 GOSUB *BUTAI:GOTO *MAINLOOP 220 IF MODE=1 THEN MODE=0:GOTO 170:ELSE 170 230 IF MODE=0 THEN MODE=1:GOTO 170:ELSE 170 240 WW=WW+(WW>0)*1:GOTO 170 250 WW=WW-(WW<10000)*1:GOTO 170 260 REM 270 *MAINLOOP'--------------------------------------------------------------- 280 GOSUB *CHRKAKU:GOSUB *KEYHANTEI:GOSUB *ATARIHANTEI:GOSUB *HENSUU 290 FOR W=0 TO WW:NEXT:IF ENDF=0 THEN *MAINLOOP ELSE GOSUB *CHRKAKU:GOTO 1000 300 *KEYHANTEI'------------------------------------------------------------- 310 I2=INP(&HE2):I4=INP(&HE4):I5=INP(&HE5):I7=INP(&HE7):CONTROL1=0:CONTROL2=0 320 IF (I5 OR &HFB)<>&HFF THEN CONTROL1=1 ' 斬 [ Z ] 330 IF (I2 OR &HAF)<>&HFF THEN CONTROL1=2 ' 上 [D:F] 340 IF (I2 OR &HF7)<>&HFF THEN CONTROL1=3 ' 下 [ C ] 350 IF (I5 OR &HFE)<>&HFF THEN CONTROL1=4 ' 左 [ X ] 360 IF (I4 OR &HBF)<>&HFF THEN CONTROL1=5 ' 右 [ V ] 370 IF (I7 OR &HEF)<>&HFF THEN CONTROL2=1 ' 斬 [ , ] 380 IF (I7 OR &HF3)<>&HFF THEN CONTROL2=2 ' 上 [; :] 390 IF (I7 OR &HBF)<>&HFF THEN CONTROL2=3 ' 下 [ / ] 400 IF (I7 OR &HDF)<>&HFF THEN CONTROL2=4 ' 左 [ . ]
610 RETURN 620 *ATARIHANTEI'---------------------------------------------------------- 630 MA=X2-X1:DMG1=0:DMG2=0 640 IF MA<8 AND MA>3 AND Y1=1 AND Y2<>3 AND K1=2 THEN DMG2=50:BEEP 650 IF MA<8 AND MA>3 AND Y1=2 AND Y2<>0 AND K1=2 THEN DMG2=50:BEEP 660 IF MA<8 AND MA>3 AND Y2=1 AND Y1<>3 AND K2=2 THEN DMG1=50:BEEP 670 IF MA<8 AND MA>3 AND Y2=2 AND Y1<>0 AND K2=2 THEN DMG1=50:BEEP 680 ' 690 RETURN 700 *HENSUU'--------------------------------------------------------------- 710 IF P1F>-1 THEN 780 720 ON CONTROL1 GOTO 730,740,750,760,770:GOTO 780 730 IF K1=0 THEN K1=1:P1F=5:GOTO 780 ELSE 780 740 IF Y1=2THEN Y1=1:GOTO 780:ELSE IF Y1=1THEN Y1=0:P1F=10:GOTO 780ELSE 4040 750 IF Y1=1THEN Y1=2:GOTO 780:ELSE IF Y1=2THEN Y1=3:P1F=10:GOTO 780ELSE 4040 760 IF X1>9 THEN X1=X1-1:GOTO 780:ELSE 780 770 IF X1<69 AND X2-X1>3 THEN X1=X1+1 780 IF P1F=>0 THEN P1F=P1F-1 790 IF Y1=3 AND P1F=0 THEN Y1=2 ELSE IF Y1=0 AND P1F=0 THEN Y1=1 800 IF K1=1 AND P1F=0 THEN K1=2:P1F=4 ELSE IF K1=2 AND P1F=0 THEN K1=0:P1F=4
810 IF P2F>-1 THEN 880 820 ON CONTROL2 GOTO 830,840,850,860,870:GOTO 880 830 IF K2=0 THEN K2=1:P2F=5:GOTO 880 ELSE 880 840 IF Y2=2THEN Y2=1:GOTO 880:ELSE IF Y2=1THEN Y2=0:P2F=10:GOTO 880ELSE 4140 850 IF Y2=1THEN Y2=2:GOTO 880:ELSE IF Y2=2THEN Y2=3:P2F=10:GOTO 880ELSE 4140 860 IF X2>9 AND X2-X1>3 THEN X2=X2-1:GOTO 880:ELSE 880 870 IF X2<66 THEN X2=X2+1 880 IF P2F=>0 THEN P2F=P2F-1 890 IF Y2=3 AND P2F=0 THEN Y2=2 ELSE IF Y2=0 AND P2F=0 THEN Y2=1 900 IF K2=1 AND P2F=0 THEN K2=2:P2F=4 ELSE IF K2=2 AND P2F=0 THEN K2=0:P2F=4 910 HP1=HP1-DMG1:HP2=HP2-DMG2 920 IF HP1<1 AND HP2<1 THEN ENDF=3 ELSE IF HP1<1 THEN ENDF=2 ELSE IF HP2<1 THEN ENDF=1 930 RETURN 940 *BUTAI'--------------------------------------------------------------- 950 X1=19:Y1=1:K1=0:X2=56:Y2=1:K2=0:HP1=1000:HP2=1000+50*KATINUKI:ENDF=0 960 CLS:FOR I=0 TO 2:LOCATE 9-I*2,20+I:COLOR 4:PRINT STRING$(60+I*4,"^"):NEXT 970 IF MODE=0 THEN LOCATE 10,1:COLOR 6:PRINT"カチヌキスウ:"KATINUKI 980 IF MODE=0 THEN LOCATE 30,0:PRINT"サイコウ カチヌキスウ:"HKATINUKI 990 FOR I=0 TO 10000:NEXT:BEEP:RETURN 1000 LOCATE 29,10:IF ENDF<3 THEN PRINT ENDF"PLAYER WIN":GOTO 1020 1010 PRINT" DRAW GAME" 1020 FOR I=0 TO 10000:NEXT 1030 IF ENDF=1 THEN KATINUKI=KATINUKI+1 1040 IF KATINUKI>HKATINUKI THEN HKATINUKI=KATINUKI 1050 GOSUB *KEYHANTEI:ON CONTROL1 GOTO 1060:GOTO 1050 1060 IF MODE=0 AND ENDF=1 THEN GOSUB *BUTAI:GOTO *MAINLOOP 1070 GOTO *TITLE
10 CLS 20 INPUT "LENGTH = ";LENGTH 30 FOR I=1 TO LENGTH 40 FOR J=LENGTH TO 1 STEP -1 50 IF I>=J THEN PRINT "W"; ELSE PRINT "A"; 60 NEXT J 70 PRINT 80 NEXT I
100 CLS 110 MA=10:MB=15:SC=3:US$=STRING$(SC,"#") 120 ' 130 LOCATE 0,1:PRINT "A" 140 FOR A=1 TO MA:PRINT MID$(STR$(A),2):NEXT A 150 LOCATE 3,0:PRINT "B"; 160 FOR B=1 TO MB:PRINT RIGHT$(SPACE$(SC)+STR$(B),SC);:NEXT B 170 ' 180 FOR A=1 TO MA:FOR B=1 TO MB 190 LOCATE SC*(B-1)+4,A+1:PRINT USING US$;(A+B) 200 NEXT B:NEXT A 210 ' 220 END
>>274は皮肉だと思われ 10 CLS 20 PRINT" B"; 30 FOR I=1 TO 15:PRINT USING"###";I;:NEXT 40 PRINT:PRINT"A" 50 FOR I=1 TO 10:PRINT USING"## ";I; 60 FOR J=1 TO 15:PRINT USING"###";I+J; 70 NEXT:PRINT:NEXT 80 END
FOR-NEXTからの脱出についてですが、 FOR K=0 TO 10 ・・・・・・・・・・・・・・・ IF A=10 THEN K=20:GOTO 10 ・・・・・・・・・・・・・・・ NEXT K として、NEXT終了後に、K=11ならばちゃんとFOR-NEXTのループから自然に抜け、 K=21ならば、強制的に抜けたと区別して判断してはどうですか? (FOR-NEXTの強制脱出について)
>>282-283 >判断してはどうですか? って、別にいいと思いますよ。ちなみに FOR K=0 TO 10 ・・・・・・・・・・・・・・・ IF A=10 GOTO 10 ・・・・・・・・・・・・・・・ NEXT K 10 IF K>10 THEN 最後までループした時の処理 ELSE 強制中断時の処理
100 REM 2以上の自然数を入力すると,素数か否かを判定する 105 INPUT n 110 FOR j=2 to n 120 IF MOD(j,2)=0 THEN 130 IF j=2 THEN PRINT using "#####":j 140 ELSE 150 FOR i=3 TO SQR(j) STEP 2 160 IF MOD(j,i)=0 THEN EXIT FOR 170 NEXT i 180 IF i>SQR(j) THEN PRINT using "#####":j 190 END IF 195 next J 200 END
100 REM 2以上の自然数を入力すると,素数か否かを判定する 110 INPUT N 120 FOR J=2 TO N 130 IF (J MOD 2)<>0 THEN GOTO *LELSE 140 *LTHEN 150 IF (J=2) THEN PRINT USING "#####";J 160 GOTO *LENDIF 170 *LELSE 180 I=3 190 WHILE ((J MOD I) <> 0) AND (I <= SQR(J)) 200 I=I+2 210 WEND 220 IF I>SQR(J) THEN PRINT USING "#####";J 230 *LENDIF 240 NEXT J 250 END
100 print "2以上の自然数を入力すると,素数か否かを判定する" 110 INPUT n 120 FOR j = 2 to n 130 IF j=2 THEN PRINT using "#####";j; 140 FOR i=3 TO J STEP 2 150 NEXT i 160 IF i>SQR(j) THEN PRINT using "#####";j; 170 next J
100 CLS 110 PRINT "2以上の自然数を入力すると,素数か否かを判定する" 120 INPUT N 130 FOR J=2 TO N 140 CNT=0 150 FOR I=2 TO J 160 IF (J MOD I)=0 THEN CNT=CNT+1 170 NEXT I 180 IF CNT=1 THEN PRINT USING "#####";J; 190 NEXT J 200 END
100 CLS 110 PRINT "2以上の自然数を入力すると,素数か否かを判定する" 120 INPUT N 130 FOR J=2 TO N 140 CNT=0 150 IF (J MOD 2)=0 THEN IF (J=2) THEN 190 ELSE 200 160 FOR I=3 TO SQR(J) STEP 2 170 IF (J MOD I)=0 THEN CNT=CNT+1 180 NEXT I 190 IF (CNT=0) THEN PRINT USING "#####";J; 200 NEXT J 210 END
10 'file=中間試験 数字 20 cls 3:def fny(y)=399-y 25 '----------------------------------------- 30 '十の位−横上 31 line step(120,100)-step(80,20),7,BF 40 '十の位−横中 41 line step(-80,80)-step(80,20),7,BF 50 '十の位−横下 51 line step(-80,80)-step(80,20),7,BF 60 '十の位−縦左上 61 line step(-100,-200)-step(20,80),7,BF 70 '十の位−縦左下 71 line step(-20,20)-step(20,80),7,BF 80 '十の位−縦右上 81 line step(80,-180)-step(20,80),7,BF 90 '十の位−縦右下 91 line step(-20,20)-step(20,80),7,BF 100 '一の位−横上 101 line step(100,-200)-step(80,20),7,BF 110 '一の位−横中 111 line step(-80,80)-step(80,20),7,BF 120 '一の位−横下 121 line step(-80,80)-step(80,20),7,BF 130 '一の位−縦左上 131 line step(-100,-200)-step(20,80),7,BF 140 '一の位−縦左下 141 line step(-20,20)-step(20,80),7,BF 150 '一の位−縦右上 151 line step(80,-180)-step(20,80),7,BF 160 '一の位−縦右下 161 line step(-20,20)-step(20,80),7,BF 180 '数字の入力 181 input "00から99までの数字を入力してください→";DT 182 DT=10A+B 183 for A=0 to 9 184 for B=0 to 9 200 '結果の出力(十の位) 201 '0 202 if A=0 then line (120,200)-(200,220),0,BF 210 '1 211 if A=1 then line (120,100)-(200,120),0,BF;line (120,200)-(200,220),0,BF;line (120,300)-(200,320),0,BF;line (100,120)-(120,200),0,BF;line (100,220)-(120,300),0,BF : :
200 '結果の出力(十の位) 201 '0 202 if A=0 then line (120,200)-(200,220),0,BF 210 '1 211 if A=1 then line (120,100)-(200,120),0,BF;line (120,200)-(200,220),0,BF;line (120,300)-(200,320),0,BF;line (100,120)-(120,200),0,BF;line (100,220)-(120,300),0,BF 220 '2 221 if A=2 then line (100,120)-(120,200),0,BF;line (200,220)-(220,300),0,BF 230 '3 231 if A=3 then line (100,120)-(120,200),0,BF;line (100,220)-(120,300),0,BF 240 '4 241 if A=4 then line (100,220)-(120,300),0,BF;line (120,100)-(200,120),0,BF;line (120,300)-(200,320),0,BF 250 '5 251 if A=5 then line (100,220)-(120,300),0,BF;line (200,120)-(220,200),0,BF 260 '6 261 if A=6 then line (200,120)-(220,200),0,BF 270 '7 271 if A=7 then line (100,120)-(120,200),0,BF;line (100,220)-(120,300),0,BF;line (120,200)-(200,220),0,BF;line (120,300)-(200,320),0,BF 280 '8 281 if A=8 then line (100,100)-(101,101),0,BF 290 '9 291 if A=9 then line (100,220)-(120,300),0,BF 300 '(一の位) 301 '0 302 if B=0 then line (320,200)-(400,220),0,BF 310 '1 311 if B=1 then line (320,300)-(400,320),0,BF;line (320,200)-(400,220),0,BF;line (320,300)-(400,320),0,BF;line (300,120)-(320,200),0,BF;line (300,220)-(320,300),0,BF 320 '2 321 if B=2 then line (300,120)-(320,200),0,BF;line (400,220)-(420,300),0,BF 330 '3 331 if B=3 then line (300,120)-(320,200),0,BF;line (300,220)-(320,300),0,BF 340 '4 341 if B=4 then line (300,220)-(320,300),0,BF;line (320,100)-(400,120),0,BF;line (320,300)-(400,320),0,BF 350 '5 351 if B=5 then line (300,220)-(320,300),0,BF;line (400,120)-(420,200),0,BF 360 '6 361 if B=6 then line (400,120)-(420,200),0,BF 370 '7 371 if B=7 then line (300,120)-(320,200),0,BF;line (300,220)-(320,300),0,BF;line (320,200)-(400,220),0,BF;line (320,300)-(400,320),0,BF 380 '8 381 if B=8 then line (300,100)-(301,101),0,BF 390 '9 391 if B=9 then line (300,220)-(320,300),0,BF 400 end
10 WIDTH 50,20:PRINT "おためしRPG ぷっしゅ えに〜 き〜":XX=29:YY=29:XXX=29:YYY=0:XXXX=0:YYYY=29:X=0:Y=0:LL=20:YU=0 20 OPEN "TEN.DLL" FOR INPUT AS #1 30 INPUT #1,TEN,NAME$ 40 CLOSE #1 50 PRINT "はいすこあ",NAME$,TEN 60 J$=INKEY$ 70 IF J$="" THEN 60 ELSE 80 80 LLL=LL/3:LLLL=LL*2/3 90 WIDTH 30,33 100 CLS 110 LOCATE X,Y:PRINT "A" 120 LOCATE XX,YY:PRINT "O" 130 LOCATE XXX,YYY:PRINT "O" 140 LOCATE XXXX,YYYY:PRINT "O" 150 LOCATE 24,31:YU=YU+1:PRINT YU 160 IF (X=XX AND Y=YY) OR (X=XXX AND Y=YYY) OR (X=XXXX AND Y=YYYY) THEN GOTO 410 170 N$=INKEY$ 180 IF N$="1" THEN X=X-1:IF X=<0 THEN X=0 190 IF N$="3" THEN X=X+1:IF X=>29 THEN X=29 200 IF N$="5" THEN Y=Y-1:IF Y=<0 THEN Y=0 210 IF N$="2" THEN Y=Y+1:IF Y=>29 THEN Y=29 220 L=L+1:IF L>=LL+1 THEN L=1 230 IF L=1 THEN 240 ELSE 280 240 IF XX>X THEN XX=XX-1:IF XX=<0 THEN XX=0 250 IF XX<X THEN XX=XX+1:IF XX=>29 THEN XX=29 260 IF YY>Y THEN YY=YY-1:IF YY=<0 THEN YY=0 270 IF YY<Y THEN YY=YY+1:IF YY=>29 THEN YY=29 280 LLL=LLL+1:IF LLL>=LL+1 THEN LLL=1 290 IF LLL=1 THEN 300 ELSE 340 300 IF XXX>X THEN XXX=XXX-1:IF XXX=<0 THEN XXX=0 310 IF XXX<X THEN XXX=XXX+1:IF XXX=>29 THEN XXX=29 320 IF YYY>Y THEN YYY=YYY-1:IF YYY=<0 THEN YYY=0 330 IF YYY<Y THEN YYY=YYY+1:IF YYY=>29 THEN YYY=29 340 LLLL=LLLL+1:IF LLLL>=LL+1 THEN LLLL=1 350 IF LLLL=1 THEN 360 ELSE 400 360 IF XXXX>X THEN XXXX=XXXX-1:IF XXXX=<0 THEN XXXX=0 370 IF XXXX<X THEN XXXX=XXXX+1:IF XXXX=>29 THEN XXXX=29 380 IF YYYY>Y THEN YYYY=YYYY-1:IF YYYY=<0 THEN YYYY=0 390 IF YYYY<Y THEN YYYY=YYYY+1:IF YYYY=>29 THEN YYYY=29 400 LL=LL-0.01:GOTO 100 410 CLS:PRINT "終〜了〜" 420 PRINT "得点",YU 430 OPEN "TEN.DLL" FOR INPUT AS #1 440 INPUT #1,UESC 450 CLOSE #1 460 IF UESC>YU THEN 520 470 INPUT "なまえをにゅうりょく",NAME$ 480 OPEN "TEN.DLL" FOR OUTPUT AS #1 490 PRINT #1,YU,NAME$ 500 CLOSE #1 510 GOTO 520 520 PRINT "ぷっしゅ えに〜 き〜" 530 J$=INKEY$ 540 IF J$="" THEN 530 ELSE 10
1 CLS 2 FOR I=0 TO 5000 3 RANDOMIZE:CCC=INT(RND*6)+1 4 COLOR CCC 5 X=X+1:IF X=79 THEN X=1:Y=Y+1:IF Y=25 THEN Y=1 6 LOCATE X,Y:PRINT "17けたのけ〜さんき" 7 NEXT I 8 FOR I=0 TO 1000:NEXT I 10 CLS 100 COLOR 3:INPUT "",A# 110 COLOR 4:INPUT "",B$ 120 COLOR 5:INPUT "",C# 125 COLOR 6 130 IF B$="+" THEN GOSUB *H 131 IF B$="-" THEN GOSUB *J 132 IF B$="*" THEN GOSUB *K 133 IF B$="/" THEN GOSUB *L 135 GOTO 100
10 CLS 11 COLOR 6:PRINT "すろっとげえむ" 20 A$(1)="7":A$(2)="Q":A$(3)="S":A$(4)="\":A$(5)="Y" 30 FOR I=1 TO 3 40 Y=Y+1:IF Y=6 THEN Y=1 50 IF INKEY$=" " THEN 80 ELSE 60 60 LOCATE 13+2*I,7:COLOR 7:PRINT A$(Y):B$(I)=A$(Y) 70 GOTO 40 80 NEXT I 90 IF B$(1)=B$(2) THEN C$="SCORE 500" ELSE C$="SCORE 0" 95 IF B$(2)=B$(3) THEN C$="SCORE 300" 96 IF B$(1)=B$(3) THEN C$="SCORE 100" 100 IF B$(1)=B$(2) AND B$(1)=B$(3) THEN C$="SCORE 1000" 110 COLOR 1:PRINT C$ 120 FOR R=0 TO 15000 130 NEXT R 140 GOTO 10
100 CLS 3:X=37:Y=11:SC=0:LI=3 110 EX(1)=10:EY(1)=5 120 EX(2)=30:EY(2)=15 130 EX(3)=50:EY(3)=10 140 LOCATE X,Y:PRINT "-<*>-" 150 '1ターン開始 160 A$=INKEY$ 170 FOR L=1 TO 3:AA(L)=0:AB(L)=0:NEXT L
180 LOCATE 1,1:PRINT "SCORE:";SC 190 LOCATE 1,2:PRINT "LIFE :";LI 200 IF LI<1 THEN END
220 GOSUB *JIKI:GOSUB *ATARI 230 GOSUB *MISSILE:GOSUB *ATARI:GOSUB *MISSILE 240 GOSUB *ATARI:GOSUB *TEKI:GOSUB *ATARI 250 GOTO 150:' 1ターン終了 260 *JIKI 270 LOCATE X,Y:PRINT " " 280 IF A$="5" THEN Y=Y-1:IF Y<1 THEN Y=1 290 IF A$="2" THEN Y=Y+1:IF Y>22 THEN Y=22 300 IF A$="1" THEN X=X-1:IF X<1 THEN X=1 310 IF A$="3" THEN X=X+1:IF X>74 THEN X=74 320 LOCATE X,Y:PRINT "-<*>-" 330 RETURN 340 *MISSILE 350 LOCATE MX,MY:PRINT " " 360 IF M=1 THEN 390 370 IF A$=" " THEN M=1:MX=X+2:MY=Y 380 IF M=0 THEN RETURN 390 MY=MY-1:IF MY<1 THEN M=0 400 LOCATE MX,MY:PRINT "|" 410 RETURN 420 *TEKI 425 FG=SC/10+3 430 FOR L=1 TO FG 440 LOCATE EX(L),EY(L):PRINT " " 450 G=INT(RND*2) 460 IF G=1 THEN EX(L)=EX(L)-1:IF EX(L)<1 THEN EX(L)=76:GOTO 480 470 EX(L)=EX(L)+1:IF EX(L)>76 THEN EX(L)=1 480 EY(L)=EY(L)+1:IF EY(L)>22 THEN EY(L)=1 490 LOCATE EX(L),EY(L):PRINT "=@=" 500 NEXT L 510 RETURN 520 *ATARI 530 FOR L=1 TO 3 540 IF AA(L)=1 THEN 560 550 IF MX=EX(L)+1 AND MY=EY(L) THEN BEEP:SC=SC+10:EY(L)=1:AA(L)=1 560 IF AB(L)=1 THEN 580 570 IF X=EX(L)-1 AND Y=EY(L) THEN BEEP:LI=LI-1:AB(L)=1 580 NEXT L 590 RETURN
10 PRINT "おためしRPG":XX=29:YY=29:X=0:Y=0:YU=3000 12 INPUT "反応速度 1/",LL 15 CLS 20 LOCATE X,Y:PRINT "A" 25 LOCATE XX,YY:PRINT "O" 26 LOCATE 24,31:PRINT YU:YU=YU-1:IF YU=0 THEN PRINT "あなたの勝ち":GOTO 1100 28 IF X=XX AND Y=YY THEN PRINT "あなたの負け":GOTO 1100 30 N$=INKEY$ 40 IF N$="1" THEN X=X-1:IF X=<0 THEN X=0 50 IF N$="3" THEN X=X+1:IF X=>29 THEN X=29 60 IF N$="5" THEN Y=Y-1:IF Y=<0 THEN Y=0 70 IF N$="2" THEN Y=Y+1:IF Y=>29 THEN Y=29 71 L=L+1:IF L=LL+1 THEN L=1 72 IF L=1 THEN 75 ELSE 1000 75 IF XX>X THEN XX=XX-1:IF XX=<0 THEN XX=0 76 IF XX<X THEN XX=XX+1:IF XX=>29 THEN XX=29 77 IF YY>Y THEN YY=YY-1:IF YY=<0 THEN YY=0 78 IF YY<Y THEN YY=YY+1:IF YY=>29 THEN YY=29 1000 GOTO 15
迷路を作成し、通路を見つけるプログラム。 1000 CONSOLE ,,0,25:SCREEN 3,1,0,1:COLOR ,,,,2:CLS 3 1010 T=VAL(MID$(TIME$,4,2))*VAL(MID$(TIME$,7,2)):RANDOMIZE T 1020 DIM A(49,49) 1030 FOR I=0 TO 49:FOR J=0 TO 49:A(I,J)=1 1040 A(0,J)=7:A(49,J)=7:NEXT J 1050 A(I,0)=7:A(I,49)=7:NEXT I 1060 LINE(0,0)-(399,399),7,BF:LINE(8,8)-(391,391),1,BF 1070 X=INT(RND*38)+1:A(X,0)=5:Y=1:LINE(X*8,0)-(X*8+7,7),0,BF:XS=X:YS=Y 1080 A(X,Y)=0:LINE(X*8,Y*8)-(X*8+7,Y*8+7),0,BF 1090 IF A(X-1,Y)=6 THEN A(X-1,Y)=7:LINE((X-1)*8,Y*8)-((X-1)*8+7,Y*8+7),7,BF 1100 IF A(X+1,Y)=6 THEN A(X+1,Y)=7:LINE((X+1)*8,Y*8)-((X+1)*8+7,Y*8+7),7,BF 1110 IF A(X,Y-1)=6 THEN A(X,Y-1)=7:LINE(X*8,(Y-1)*8)-(X*8+7,(Y-1)*8+7),7,BF 1120 IF A(X,Y+1)=6 THEN A(X,Y+1)=7:LINE(X*8,(Y+1)*8)-(X*8+7,(Y+1)*8+7),7,BF 1130 IF A(X-1,Y)=1 THEN A(X-1,Y)=6:LINE((X-1)*8,Y*8)-((X-1)*8+7,Y*8+7),6,BF 1140 IF A(X+1,Y)=1 THEN A(X+1,Y)=6:LINE((X+1)*8,Y*8)-((X+1)*8+7,Y*8+7),6,BF 1150 IF A(X,Y-1)=1 THEN A(X,Y-1)=6:LINE(X*8,(Y-1)*8)-(X*8+7,(Y-1)*8+7),6,BF 1160 IF A(X,Y+1)=1 THEN A(X,Y+1)=6:LINE(X*8,(Y+1)*8)-(X*8+7,(Y+1)*8+7),6,BF 1170 IF A(X-1,Y)=6 OR A(X+1,Y)=6 THEN 1190 1180 IF A(X,Y-1)=6 OR A(X,Y+1)=6 THEN 1190 ELSE GOTO 1280 1190 D=INT(RND*4)+1:ON D GOTO 1200,1220,1240,1260 1200 IF A(X-1,Y)<>6 THEN 1190 1210 X=X-1:GOTO 1080 1220 IF A(X+1,Y)<>6 THEN 1190 1230 X=X+1:GOTO 1080 1240 IF A(X,Y-1)<>6 THEN 1190 1250 Y=Y-1:GOTO 1080 1260 IF A(X,Y+1)<>6 THEN 1190 1270 Y=Y+1:GOTO 1080 1280 FOR J=1 TO 48:FOR I=1 TO 48 1290 IF A(I,J)=6 THEN 1310 1300 NEXT I,J:GOTO 1350 1310 IF A(I-1,J)=1 OR A(I+1,J)=1 THEN 1330 1320 IF A(I,J-1)=1 OR A(I,J+1)=1 THEN 1330 ELSE GOTO 1340 1330 X=I:Y=J:GOTO 1080 1340 A(I,J)=7:LINE(I*8,J*8)-(I*8+7,J*8+7),7,BF:GOTO 1300 1350 E=INT(RND*38)+1:IF A(E,48)<>0 THEN 1350 1360 A(E,49)=0:LINE(E*8,392)-(E*8+7,399),0,BF:XE=E:YE=49 1370 FOR I=1 TO 48:FOR J=1 TO 48 1380 IF A(I,J)=1 THEN A(I,J)=7:LINE(I*8,J*8)-(I*8+7,J*8+7),7,BF 1390 NEXT J,I 1400 LINE(XS*8,0)-(XS*8+7,7),2,BF 1410 LINE(XS*8,YS*8)-(XS*8+7,YS*8+7),2,BF:A(XS,YS)=2 1420 IF YS=49 THEN STOP:GOTO 1030 1430 IF A(XS-1,YS)=0 THEN XS=XS-1:GOTO 1410 1440 IF A(XS+1,YS)=0 THEN XS=XS+1:GOTO 1410 1450 IF A(XS,YS-1)=0 THEN YS=YS-1:GOTO 1410 1460 IF A(XS,YS+1)=0 THEN YS=YS+1:GOTO 1410 1470 LINE(XS*8,YS*8)-(XS*8+7,YS*8+7),8,BF:A(XS,YS)=1 1480 IF A(XS-1,YS)=2 THEN XS=XS-1:GOTO 1410 1490 IF A(XS+1,YS)=2 THEN XS=XS+1:GOTO 1410 1500 IF A(XS,YS-1)=2 THEN YS=YS-1:GOTO 1410 1510 IF A(XS,YS+1)=2 THEN YS=YS+1:GOTO 1410 1520 GOTO 1410
あの・・・ここのソース見てて思ったんだけど、論理式ってメジャーじゃないのかな。 たとえばキーの判定とかでよく if k$="4" then x=x-1 if k$="6" then x=x+1 とかやってる人いるけど、これは x=x+(k$="4")-(k$="6") で置き換えられる。 こっちのほうがスマートだし処理速度も速いと思う。
10 cls :r=0 20 input"k=";k:cls 30 line(0,0)-(200,200),3,b 40 circle(0,0),200,3 50 for i=1 to k 60 x=rnd*1:y=rnd*1 70 n=x*x+y*y:c=3 80 if n<=1 then 90 else 100 90 r=r+1:c=5 100 circle(x*200,y*200),1,c 110 next i 120 pi=4*r/k 130 locate 20,20:print "r=";r,"pi=";pi 140 end
100 SCREEN 3,0,0,1: CLS 3 110 RESTORE 120 FOR Y=0 TO 15 130 READ A$ 135 WINDOW (0,0)-(100,100) 137 VIEW (100,100)-(300,300) 140 FOR X=0 TO 15 150 B$=MID$(A$,X+1,1) 160 COL=VAL(B$) 170 PSET (X,Y),COL 180 NEXT X 190 NEXT Y 200 END 210 ' 220 DATA 7777777777777777 230 DATA 7772777227772777 240 DATA 7722772222772277 250 DATA 7722272222722277 260 DATA 7722222222222277 270 DATA 7722222222222277 280 DATA 7722222222222277 290 DATA 7772222222222777 300 DATA 7777722222277777 310 DATA 7444777447774447 320 DATA 7444477447744447 330 DATA 7444447447444447 340 DATA 7744447447444477 350 DATA 7774447447444777 360 DATA 7777447447447777 370 DATA 7777777777777777
円周率を求めるプログラムを区分求積法でやってみましたが・・・ 10 x=0:r=1:s=0 20 input a 30 for b=1 to a 40 x=x+(r/a) 50 y=(r*r-x*x)^(1/2) 60 h=y*(r/a) 70 s=s+h 80 next b 90 p=4s 100 print p 110 end