#include <iostream.h>
#include <stdio.h>
void hanoi(int n,char x,char y,char z);
void move(char x,int n,char y);
void main()
{
int num;
char A,B,C;
cout<<"Please enter the number of disks num:";
cin>>num;
hanoi(num,A,B,C);
}
void hanoi(int n,char x,char y,char z)
{
if(n==1)
move(x,1,z);
else{
hanoi(n-1,x,z,y);
move(x,n,z);
hanoi(n-1,y,x,z);
}
}
void move(char x,int n,char y)
{
cout <<"move\t"<<n<<"from\t"<<x<< "to"<< y<<endl;
}
程序没有错误
但运行的时候却有乱码
最后一行是不是写法不正确 ?