#include <stdio.h>
int hj(int a,int b,int c,int i)
{
int t;
if(i==1)
printf("%d->%d\n",a,c);//最后一步
else
{
t = c;
c = b;
b = t;
hj(a,b,c,i-1);
printf("%d->%d\n",a,b);
t = a;
a = c;
c = t;
t = b;
b = c;
c = t;
hj(a,b,c,i-1);
return 0;
}
}
int main()
{
int a,b,c,i;
a = 1;
b = 2;
c = 3;
printf("请输入你的盘数");
scanf("%d",&i);
hj(a,b,c,i);
return 0;
}
汉洛塔斐波那契数列
最新推荐文章于 2024-10-31 09:15:43 发布