#include <bits/stdc++.h>
using namespace std;
void hannota(int n,char a,char b,char c)
{
if(n==1)
printf("number..%d..form..%c..to..%c\n",n,a,c);
else
{
hannota(n-1,a,c,b);
printf("number..%d..form..%c..to..%c\n",n,a,c);
hannota(n-1,b,a,c);
}
}
int main()
{
int n;
char a='A',b='B',c='C';
while(cin>>n)
{
hannota(n,a,b,c);
}
return 0;
}
汉诺塔递归nefu 564
最新推荐文章于 2022-11-27 15:11:13 发布