program hanoi_towers;
uses crt;
const A=1;
const B=2;
const C=3;
procedure mouvement(origine,destination:integer;var cpt:integer);
begin
writeln('mouvement ',origine,' ----> ',destination);
cpt:=cpt+1
end;
procedure hanoi_aux(n:integer;ori,inter,dest:integer; var compt:integer);
begin
if n=1 then mouvement(ori,dest,compt)
else
begin
hanoi_aux(n-1,ori,dest,inter,compt);
mouvement(ori,dest,compt);
hanoi_aux(n-1,inter,ori,dest,compt);
end;
end;
procedure hanoi(n:integer);
var compt : integer;
begin
compt:=0;
hanoi_aux(n,A,B,C,compt);
writeln('nb de mouvements' , compt);
end;
var n: integer;
begin
write('entrez n :');
readln(n);
hanoi(n);
readln;
end.