Skip to content

Commit abc4748

Browse files
authored
Update Tower of Hanoi.cpp
1 parent 98cea57 commit abc4748

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Tower of Hanoi.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ void towers(int num, char frompeg, char topeg, char auxpeg)
2727
{
2828
if (num == 1)
2929
{
30-
printf("\n Move disk 1 from peg %c to peg %c", frompeg, topeg);
30+
printf("\n Move disk 1 from peg %c to peg %c", frompeg, topeg); //move 1 disk from A to C
3131
m++;
3232
return;
3333
}
34-
towers(num - 1, frompeg, auxpeg, topeg);
34+
towers(num - 1, frompeg, auxpeg, topeg); //move n-1 disks from A to B using C
3535
printf("\n Move disk %d from peg %c to peg %c", num, frompeg, topeg);
3636
m++;
37-
towers(num - 1, auxpeg, topeg, frompeg);
37+
towers(num - 1, auxpeg, topeg, frompeg); //move n-1 disks from B to C using A
3838
}
3939

4040

0 commit comments

Comments
 (0)