|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include <stdio.h>
void main()
{
void hanoi(int n,char one,char two,char three);
/* 对hanoi函数的声明 */
int m;
printf("input the number of diskes:");
scanf("%d", &m);
printf("The step to moveing %d diskes:\n", m);
hanoi(m, 'A', 'B', 'C');
}
void hanoi(int n, char one, char two, char three)
/* 定义hanoi函数, 将n个盘从one座借助two座,移到three座 */
{
void move(char x, char y); /* 对move函数的声明 */
if( n==1 )
{
move(one, three);
}
else
{
hanoi(n-1, one, three, two);
move(one,three);
hanoi(n-1,two,one,three);
}
}
void move(char x, char y) /* 定义move函数 */
{
printf("%c-->%c\n", x, y);
}
汉诺塔那个过程明白了,但是这个程序看不明白,麻烦高人给指点下;
快被这个汉诺塔整疯了,调试也不知这个程序是怎么打印出来的,按理说不是只能打印出来A->C吗?A-->B,B-->C啥的是怎么打印出来的,还有就是他那个循环是怎么给整出来的啊,还有就是move不是one three吗?怎么还变成ABC啦 |
|