当前位置: 首页 > 都市小说 > 都市暧昧> 电子生涯 > 游戏汉诺塔源代码
游戏汉诺塔源代码
作者:范含  |  字数:2055  |  更新时间:2026-01-10 全文阅读

  focalдbasicfortran

  01.01chanoibydec

  01.02cfromprogramminglanguages

  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.13cdependingonhowyouanswerthemovesorplotsquestion.

  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.30a"no.ofdisks"n,!

  01.40fi=1,n;sss(i)=i

  01.50sso=1;ssi=3

  01.60sno=n;sni=n;si=0

  01.70a"movesorplots",move,!

  01.80i(fabs(mo-0moves)),1.85;d23

  01.85a"autoormanual",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.95d3;d6;r

  03.10sni=n

  03.20i[ss((si-1)*n ni)]er,3.3;sni=ni-1;g3.2

  03.30r

  05.10a&quot;out-disc:&quot;,no,&quot;tower:&quot;,so

  05.20a!&quot;in-disc:&quot;,ni,&quot;tower:&quot;,si,!;d6

  05.30sa=0

  05.40fi=1,n*2;sa=a ss(i)

  05.50i(-a)5.1;t!&quot;welldone!&quot;!;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&quot;#

  23.60i(k-35 ss(j n)*2)23.7;i(-k 35 ss(j n)*2)23.7;t&quot;#

  23.70i(k-55 ss(j n n)*2)23.8;i(-k 55 ss(j n n)*2)23.77;t&quot;#

  23.77sk=100;r

  23.80t&quot;&quot;

捧场

按“键盘左键←”返回上一章   按“键盘右键→”进入下一章   按“空格键”向下滚动

章节评论

发表章评

    设置

    阅读背景
    字体大小
    A-
    16
    A+
    页面宽度