program Hanoj;
{Reseni problemu Hanojskych vezi}

{
 Prenese vez o x kotoucich z jehly a na jedhlu b.
 Pouzije jehlu c jako odkladaci
}
procedure PrenesVez(x,a,b,c: integer);
begin
  if x>0 then
    begin
      PrenesVez(x-1,a,c,b); {Zmensime problem}
      writeln('Prenes kotouc z ', a, ' na ', b); {Presun nejvetsiho kotouce}
      PrenesVez(x-1,c,b,a) {Vratime odlozene kotouce}
    end
end;

var 
  x : integer;
begin
  write('Zadejte pocet kotoucu kotoucu: ');
  readln(x);
  PrenesVez(x,1,2,3)
end.

