汉诺塔问题
#include<iostream>
using namespace std;
int a=0;
const int max=10000;
int main()
{
void hanoi(int n,char one,char two,char three);
//int m[max];
//for(int i=0;i<max;i++)
// cin>>m[i];
int m;
cin>>m;
hanoi(m,'A','B','C');
cout<<endl;
return 0;
}
void hanoi(int n,char one,char two,char three)
{ int j;
void move(char x,char y);
if(n==1)move(one,three);
else
{ int i=0;
hanoi((n-1),one,three,two);
move(one,three);
hanoi((n-1),two,one,three);
}
}
void move(char x,char y)
{
a++;
cout<<x<<"-->"<<y<<" ";
if(a%5==0)
cout<<endl;
}
现在只能输入一个数据,要求改成可连续输入,直到输入0时结束...
在线等哈,谢谢各位..