|
DataMuseum.dkPresents historical artifacts from the history of: RegneCentralen RC850 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about RegneCentralen RC850 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 1536 (0x600) Types: TextFile Names: »TOWER.PAS«
└─⟦9eb5585bb⟧ Bits:30005839 COMPAS Pascal v. 2.20 (RC855) └─⟦this⟧ »TOWER.PAS«
Program towerofhanoi (input, output) ; type pole = (left, middle, right) ; positiveinteger = 1..maxint ; var numberofdisks : positiveinteger ; procedure move (n : positiveinteger; source, auxiliary, destination: pole) ; procedure moveadiskfromsourcetodestination ; procedure printpole (p : pole) ; begin case p of left : write ('V ') ; middle : write (' M ') ; right : write (' H') end end ; (* printpole *) begin write ('move a disk from ') ; printpole (source) ; write (' -> ') ; printpole (destination) ; writeln ; end ; (* moveadiskfromsourcetodestination *) begin if n= 1 then moveadiskfromsourcetodestination else begin move (n-1, source, destination, auxiliary) ; moveadiskfromsourcetodestination ; move (n-1, auxiliary, source, destination) ; end end ; (* move *) begin write ('tast et tal ') ; readln (numberofdisks) ; writeln ('for' , numberofdisks:3, ' disks ' , 'the required moves are :') ; writeln ; move (numberofdisks, left, middle, right) end. «eof»