终于搞清了它的过程,但是还是不知道其中编写的奥妙,再仔细想想为什么要这样
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
#include<iostream.h>
#include<string.h>
void Hanoi(int n,char A,char B,char C);
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
void main()
{
Hanoi(3,'A','B','C');
}
![](http://www.cppblog.com/Images/OutliningIndicators/None.gif)
void Hanoi(int n,char A,char B,char C)
{
if(n==1)
cout<<"Move top disk from peg "<<A<<" to peg "<<C<<endl;
else
{
Hanoi(n-1,A,C,B);
cout<<"Move top disk from peg "<<A<<" to peg "<<C<<endl;
Hanoi(n-1,B,A,C);
}
}