When God created the world, he made three diamond pillars and placed 64 gold disks in order from bottom to bottom.
God ordered the Brahman to re-place the disc from below in order of size on another pillar. It is also stipulated that the disc cannot be enlarged on a small disc, and only one disc can be moved between the three pillars at a time.
It was predicted that the universe would flash into destruction at the completion of the event. Some people believe that Brahman is still moving the disc for a moment.
The recursive principle is used.
Code:
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Namespace HanoiProgram
{
Class Program
{
Static long count = 0;
Static void move (char x, char y)
{
Console. WriteLine ("{0} ---> {1}", x, y );
}
Static void hanoi (int n, char one, char two, char three)
{
If (n = 1)
{
Count + = 2;
Move (one, two );
Move (two, three );
}
Else
{
Count + = 2;
Hanoi (n-1, one, two, three );
Move (one, two );
Hanoi (n-1, three, two, one );
Move (two, three );
Hanoi (n-1, one, two, three );
}
}
Static void Main (string [] args)
{
Console. WriteLine ("several dishes need to be moved ");
Int n =