字体:大 中 小
护眼
关灯
上一章
目录
下一章
游戏汉诺塔源代码 (第1/1页)
这个游戏是用Focal写成,大家见识一下这种化石编程语言,至于Basic和Fortran至今都在,就不举例子了。 01.01CHANOIBYDEC 01.02CFROM‘PROGRAMMINGLANGUAGES‘ 01.03CLASTCHANGE:8/7/71 01.04 01.05CTHISPROGRAMWORKSWITHTHETOWERSOFHANOIPROBLEM. 01.06CYOUAREGIVENTHREETOWERSWITHVARIOUSSIZEDDISCSON 01.07CONEOFTHEM.THEOBJECTISTOPLACEALLTHEDISCSON 01.08CANOTHERTOWERONATATIME,WITHTHESTIPULATIONTHATA 01.09CLARGERDISCMAYNEVERBEONTOPOFASMALLERONE.THIS 01.10CPROGRAMISGOODFORANYNUMBEROFDISCSANDCANBERUN 01.11CEITHERINMANUAL(YOUTELLITWHERETOMOVE)ORAUTOMATIC 01.12CMODE.ITWILLALSOEXPLAINITSMOVESORDRAWTHEFORYOU, 01.13CDEPENDINGONHOWYOUANSWERTHE‘MOVESORPLOTS‘QUESTION. 01.14C**OUTDISCISTHEDISC(1ONTOP)THATYOUWANTTOMOVE 01.15C**INDISCISTHEPOSITION(1ONTOP)WHEREYOUMOVETO 01.16C**OUTTOWERISTHETOWER(1ONLEFT)FROMWHICHYOUMOVE 01.17C**INTOWERISTHETOWER(3ONRIGHT)YOUMOVETO 01.18CTHISPROGRAMASSUMESNOCHEATING,ANDDOESNOTCHECKFORIT. 01.19 01.29E 01.30ANO.OFDISKSN,! 01.40FI=1,N;SSS(I)=I 01.50SSO=1;SSI=3 01.60SNO=N;SNI=N;SI=0 01.70AMOVESORPLOTS,MOVE,! 01.80I(FABS(MO-0MOVES)),1.85;D23 01.85AAUTOORMANUAL,A,! 01.90I(FABS(A-0MANUAL)),5.1;D2;T!!DONE!,!!;Q 02.20I[SS<(SO-1)*N NO-1>]ER,2.95 02.30SI=I 1;SNO(I)=NO;SSO(I)=SO;SSI(I)=SI 02.50SSI=6-SO-SI;SNO=NO-1;D3;STE(I)=NI;D2 02.60SSI=SI(I);SNO=NO 1;D3;D6 02.70SSO=6-SO-SI;SNO=TE(I);D3;D2 02.80SSI=SI(I);SSO=SO(I);SNO=NO(I);SI=I-1 02.90R 02.D6;R 03.10SNI=N 03.20I[SS((SI-1)*N NI)]ER,3.3;SNI=NI-1;G3.2 03.30R 05.10AOUT-DISC:,NO,TOWER:,SO 05.20A!IN-DISC:,NI,TOWER:,SI,!;D6 05.30SA=0 05.40FI=1,N*2;SA=A SS(I) 05.50I(-A)5.1;T!WELLDONE!!;Q 06.10SDO=(SO-1)*N NO 06.20SDI=(SI-1)*N NI 06.30SSS(DI)=SS(DO) 06.40SSS(DO)=0 06.50I(MOVE)ER,6.7;D23;R 06.70T!%2,SO,NO,!SI,NI,! 23.10FJ=1,N;T!;FK=0,70;D23.3 23.20T!!!!;R 23.30I[K-15 SS(J)*2]23.6;I(-K 15 SS(J)*2)23.6;T# 23.60I(K-35 SS(J N)*2)23.7;I(-K 35 SS(J N)*2)23.7;T# 23.70I(K-55 SS(J N N)*2)23.8;I(-K 55 SS(J N N)*2)23.77;T# 23.77SK=100;R 23.80T
上一章
目录
下一章