homework5 Version 0 |
|
👤 Author: by 1561629662qqcom 2016-12-07 22:23:35 |
#include<stdio.h>
void move(int n,char a,char b,char c)
{
if(n==1)
printf("\t%c->%c\n",a,c);
else
{
move(n-1,a,c,b);
printf("\t%c->%c\n",a,c);
move(n-1,b,a,c); }
}
main()
{
int n;
printf("请输入要移动的块数:");
scanf("%d",&n);
move(n,'a','b','c');
}
Here is the C code of the Hanoi tower,which are divided into three steps. First,take the plate from a to b by c . Then ,take the last from a to c.rega