home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / MBUG / MBUG003.ARC / JRTPAS-1.LBR / GROG102.PAS next >
Pascal/Delphi Source File  |  1979-12-31  |  640b  |  22 lines

  1. Program Hanoi;
  2.     var
  3.        total : integer;
  4.     procedure movetower (height,fromneedle,toneedle,useneedle : integer);
  5.        procedure movedisk (takeoff,puton : integer);
  6.         begin
  7.                writeln(takeoff:2,' > ',puton:2)
  8.         end; (* movedisk *)
  9.         begin
  10.             if height > 0 then
  11.                     begin
  12.                     movetower(height-1,fromneedle,useneedle,toneedle);
  13.             movedisk(fromneedle,toneedle);
  14.             movetower(height-1,useneedle,toneedle,fromneedle)
  15.                     end;
  16.         end;
  17.     begin (* main program *)
  18.             writeln('How many discs?');writeln;
  19.         read (total);
  20.         movetower (total,1,3,2)
  21.     end.
  22.