dnes som skusal naprogramovat program na hanoiske veze.
program mi ide, len by som tam chcel odladit jednu malickost. ide o to ze chcem aby mi pri vystupe pisalo aj cislo kotucika ktory prenasam
(program mi pise iba z ktorej tyce na aku sa ma kotucik preniest)
dakujem
Kód: Vybrať všetko
var x:integer;
procedure PRESUN( N, odkial, kam: integer );
var pom: integer;
begin
if N=1 then
writeln(odkial, ' ---- >', kam )
else
begin
pom := 1+2+3 - odkial -kam;
PRESUN( N-1, odkial, pom );
PRESUN( 1, odkial, kam );
PRESUN( N-1, pom, kam )
end
end;
begin
read(x);
PRESUN( x, 1, 2 )
end.