Hanoi实现怎么错了
#include<iostream.h>void Move(int n,char l,char k);
void Hanoi(int n,char a,char b,char c);
int main()
{
int n;
char A,B,C;
cout<<"input n:"<<endl;
cin>>n;
Hanoi(n,A,B,C);
return 0;
}
void Move(int n,char l,char k)
{
cout<<n<<l<<"->"<<k<<endl;
}
void Hanoi(int n,char a,char b,char c)
{
char A,B,C;
if(n==1)
Move(1,A,B);
/*if(n<=0)
cout<<"Error!!!"<<endl;
else*/
if(n>0)
Hanoi(n-1,A,C,B);
Move(n,A,B);
Hanoi(n-1,C,B,A);
}
算法应该没问题了